return NULL;
} // END - if
- // Fake array
+ // Fake package instance
+ $packageInstance = new NetworkPackageHandler();
+
+ // Set all fields
+ //$packageInstance->set
$data = array(
self::PACKAGE_CONTENT_SENDER => $senderId,
self::PACKAGE_CONTENT_MESSAGE => $content,
// Hash content and sender id together, use scrypt
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content));
- $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data)));
+ $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array(
+ sprintf('%s:%s:%s',
+ $senderId,
+ $content,
+ $this->determineSenderPrivateKeyHash($data)
+ )
+ ));
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!');
$this->getHashFromContent($compressed)
);
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
-
// Make sure required data is there
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
assert(!empty($content));
assert($this->getNodeInstance()->getSessionId() != '');
*/
public function isPackageDeclared () {
// Check whether the stacker is not empty
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
$isDeclared = (
($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) &&
(!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))
);
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
-
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
return $isDeclared;
}
*/
public function isPackageWaitingForDelivery () {
// Check whether the stacker is not empty
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
$isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING)));
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
-
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
return $isWaitingDelivery;
}
*/
public function isEncodedDataPending () {
// Check whether the stacker is not empty
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
$isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM)));
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
-
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
*/
public function removeFirstFailedPackage () {
// Get the package again
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
$packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED);
// Is the package status 'failed'?
// Remove this entry
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
}
/**
*/
public function decodeRawContent ($rawPackageContent) {
// Use the separator '#' to "decode" it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: rawPackageContent()=%d - CALLED!', strlen($rawPackageContent)));
$decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent);
// Debug message
$packageInstance->setPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]);
// And return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageInstance=%s - EXIT!', $packageInstance->__toString()));
return $packageInstance;
}
*/
private $packageContent;
+ /**
+ * Sender address
+ */
+ private $senderAddress;
+
+ /**
+ * Sender port
+ */
+ private $senderPort;
+
+ /**
+ * Recipient type
+ */
+ private $recipientType;
+
+ /**
+ * Status
+ */
+ private $status;
+
/**
* Protected constructor
*
$this->packageContent = $packageContent;
}
+ /**
+ * Getter for sender address
+ *
+ * @return $senderAddress Sender address
+ */
+ public function getSenderAddress () {
+ return $this->senderAddress;
+ }
+
+ /**
+ * Setter for sender address
+ *
+ * @param $senderAddress Sender address
+ * @return void
+ */
+ public function setSenderAddress ($senderAddress) {
+ $this->senderAddress = $senderAddress;
+ }
+
+ /**
+ * Getter for sender port
+ *
+ * @return $senderPort Sender port
+ */
+ public function getSenderPort () {
+ return $this->senderPort;
+ }
+
+ /**
+ * Setter for sender port
+ *
+ * @param $senderPort Sender port
+ * @return void
+ */
+ public function setSenderPort ($senderPort) {
+ $this->senderPort = $senderPort;
+ }
+
+ /**
+ * Getter for recipient type
+ *
+ * @return $recipientType Recipient type
+ */
+ public function getRecipientType () {
+ return $this->recipientType;
+ }
+
+ /**
+ * Setter for recipient type
+ *
+ * @param $recipientType Recipient type
+ * @return void
+ */
+ public function setRecipientType ($recipientType) {
+ $this->recipientType = $recipientType;
+ }
+
+ /**
+ * Getter for status
+ *
+ * @return $status Status
+ */
+ public function getStatus () {
+ return $this->status;
+ }
+
+ /**
+ * Setter for status
+ *
+ * @param $status Status
+ * @return void
+ */
+ public function setStatus ($status) {
+ $this->status = $status;
+ }
+
/**
* Getter for content hash
*