From: Roland Häder Date: Mon, 26 Oct 2020 06:25:47 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2c91a8ab3cef9ab0bdc6da05f05918d181da4747;p=hub.git Continued: - added missing fields senderAddress, senderPort, recipientType and status Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index f489d980d..076b9c23f 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -737,7 +737,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei 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, @@ -746,7 +750,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // 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!'); @@ -827,10 +837,8 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $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() != ''); @@ -880,15 +888,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ 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; } @@ -899,12 +906,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ 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; } @@ -915,12 +921,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ 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; } @@ -1344,6 +1349,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ 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'? @@ -1354,6 +1360,9 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Remove this entry $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -1364,6 +1373,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ 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 @@ -1385,6 +1395,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $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; } diff --git a/application/hub/classes/package/deliverable/class_PackageData.php b/application/hub/classes/package/deliverable/class_PackageData.php index a37f978a8..56bc31ee3 100644 --- a/application/hub/classes/package/deliverable/class_PackageData.php +++ b/application/hub/classes/package/deliverable/class_PackageData.php @@ -42,6 +42,26 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera */ private $packageContent; + /** + * Sender address + */ + private $senderAddress; + + /** + * Sender port + */ + private $senderPort; + + /** + * Recipient type + */ + private $recipientType; + + /** + * Status + */ + private $status; + /** * Protected constructor * @@ -84,6 +104,82 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera $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 * diff --git a/contrib/update_year.sh b/contrib/update_year.sh index 560da6111..546f96ae0 100755 --- a/contrib/update_year.sh +++ b/contrib/update_year.sh @@ -1,4 +1,4 @@ #!/bin/sh # Really lame ... -find application/ -type f -print0 | xargs -0 sed -i 's/2012 Apt-Proxy/2012 - 2018 Hub/g' +find application/ -type f -print0 | xargs -0 sed -i 's/2018 Hub/2020 Hub/g'