use Org\Shipsimu\Hub\Factory\Information\Connection\ConnectionInfoFactory;
use Org\Shipsimu\Hub\Factory\Network\PackageDataFactory;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
+use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\BaseHubHandler;
use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
$dhtInstance = DhtObjectFactory::createDhtInstance('node');
// Ask DHT for session id
- $senderData = $dhtInstance->findNodeLocalBySessionId($packageInstance->getContentSender());
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Finding local node data for packageInstance->senderId=%s ...', $packageInstance->getSenderId()));
+ $senderData = $dhtInstance->findNodeLocalBySessionId($packageInstance->getSenderId());
// Debugging:
//* DEBUG-DIE: */ die(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE)));
// Is an entry found?
if (count($senderData) > 0) {
// Make sure the element 'private_key_hash' is there
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderData=' . print_r($senderData, TRUE));
assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
// Don't accept empty hashes
if (empty($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])) {
// Don't accept
- throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in senderData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+ throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in senderData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
} // END - if
// Return it
} // END - if
// Don't accept empty keys
- if (empty($packageInstance->getContentPrivateKeyHash())) {
+ if (empty($packageInstance->getSenderPrivateKeyHash())) {
// This needs fixing
- throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+ throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
} // END - if
// There is no DHT entry so, accept the hash from decoded data
- return $packageInstance->getContentPrivateKeyHash();
+ return $packageInstance->getSenderPrivateKeyHash();
}
/**
*/
private function getHashFromContent ($content) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// And return it
return $hash;
*/
public function getHashFromContentSessionId (array $decodedContent, $sessionId) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
/**
* Declares the given An instance of a DeliverablePackage class by discovering recipients
*
- * @param $packageData An instance of a DeliverablePackage class in an array
+ * @param $packageInstance An instance of a DeliverablePackage class in an array
* @return void
*/
private function declareRawPackageData (DeliverablePackage $packageInstance) {
$discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance();
// Discover all recipients, this may throw an exception
- $discoveryInstance->discoverRecipients($packageData);
+ $discoveryInstance->discoverRecipients($packageInstance);
// Now get an iterator
$iteratorInstance = $discoveryInstance->getIterator();
$currentRecipient = $iteratorInstance->current();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . packageInstance->getRecipient());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Setting recipient to ' . $currentRecipient . ',previous=' . $packageInstance->getRecipientType());
// Set the recipient
$packageInstance->setRecipient($currentRecipient);
// Push the declared package to the next stack.
- $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
+ $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package declared for recipient ' . $currentRecipient);
// Skip to next entry
$iteratorInstance->next();
* the package), register the socket with the connection (handler/helper?)
* instance and finally push the raw data on our outgoing queue.
*
- * @param $packageData An instance of a DeliverablePackage class in an array
+ * @param $packageInstance An instance of a DeliverablePackage class in an array
* @return void
*/
private function deliverRawPackageData (DeliverablePackage $packageInstance) {
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
/*
* This package may become big, depending on the shared object size or
$discoveryInstance = SocketDiscoveryFactory::createSocketDiscoveryInstance();
// Now discover the right socket instance from given package data
- $socketInstance = $discoveryInstance->discoverSocket($packageData, StorableSocket::CONNECTION_TYPE_OUTGOING);
+ $socketInstance = $discoveryInstance->discoverSocket($packageInstance, StorableSocket::CONNECTION_TYPE_OUTGOING);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
// Get the connection helper from registry
$helperInstance = GenericRegistry::getRegistry()->getInstance('connection');
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: stateInstance=' . $helperInstance->getStateInstance());
// And make sure it is valid
assert($helperInstance instanceof ConnectionHelper);
$infoInstance->fillWithConnectionHelperInformation($helperInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
// Is it not there?
if (($socketInstance->isValidSocket()) && (!$this->getRegistryInstance()->isSocketRegistered($infoInstance, $socketInstance))) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Registering socket ' . $socketInstance . ' ...');
// Then register it
$this->getRegistryInstance()->registerSocketInstance($infoInstance, $socketInstance);
} elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) {
// Is not connected, then we cannot send
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
// Shutdown the socket
$socketInstance->shutdownSocket();
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
// Make sure the connection is up
$helperInstance->getStateInstance()->validatePeerStateConnected();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
// Enqueue it again on the out-going queue, the connection is up and working at this point
- $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
+ $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
}
/**
* Sends waiting packages
*
- * @param $packageData An instance of a DeliverablePackage class
+ * @param $packageInstance An instance of a DeliverablePackage class
* @return void
*/
private function sendOutgoingRawPackageData (DeliverablePackage $packageInstance) {
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
// Init sent bytes
$sentBytes = 0;
// Get the right connection instance
- $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageData);
+ $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageInstance);
// Test helper instance
assert($infoInstance instanceof ShareableInfo);
} // END - if
// Sent out package data
- $helperInstance->sendRawPackageData($packageData);
+ $helperInstance->sendRawPackageData($packageInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
private function generatePackageHash ($content, $senderId) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
// Assert on variables
assert(!empty($content));
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
return NULL;
} // END - if
// Fake package instance
- $packageInstance = new NetworkPackageHandler();
+ $packageInstance = PackageDataFactory::createPackageDataInstance();
// Set all fields
- //$packageInstance->set
- $data = array(
- self::PACKAGE_CONTENT_SENDER => $senderId,
- self::PACKAGE_CONTENT_MESSAGE => $content,
- self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $this->getNodeInstance()->getPrivateKeyHash(),
- );
+ $packageInstance->setSenderId($senderId);
+ $packageInstance->setPackageContent($content);
+ $packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
// Hash content and sender id together, use scrypt
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderId=' . $senderId . ',content()=' . strlen($content));
$hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array(
sprintf('%s:%s:%s',
$senderId,
$content,
- $this->determineSenderPrivateKeyHash($data)
+ $this->determineSenderPrivateKeyHash($packageInstance)
)
));
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: hash=' . $hash . ' - EXIT!');
// Return it
return $hash;
*/
private function isPackageHashValid (array $decodedArray) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
// Make sure the required array elements are there
assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER]));
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature is not enabled, so hashes are always valid
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
return TRUE;
} // END - if
// Check validity
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
//* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
$isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]));
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: isHashValid=' . intval($isHashValid) . ' - EXIT!');
return $isHashValid;
}
*/
public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Get the raw content ...
$content = $helperInstance->getTemplateInstance()->getRawTemplateData();
);
// Make sure required data is there
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
assert(!empty($content));
assert($this->getNodeInstance()->getSessionId() != '');
$packageInstance->setPackageContent($packageContent);
$packageInstance->setStatus(self::PACKAGE_STATUS_NEW);
$packageInstance->setContentHash($this->generatePackageHash($content, $this->getNodeInstance()->getSessionId()));
- $packageInstance->setPrivateKeyHash($this->getNodeInstance()->getPrivateKeyHash());
+ $packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
// Now prepare the temporary array and push it on the 'undeclared' stack
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, $packageInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function isPackageEnqueued () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$isEnqueued = (
($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) &&
(!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isEnqueued=%d - EXIT!', intval($isEnqueued)));
return $isEnqueued;
}
*/
public function isPackageDeclared () {
// Check whether the stacker is not empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$isDeclared = (
($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) &&
(!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))
);
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: 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!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING)));
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: 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!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM)));
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
*/
public function declareEnqueuedPackage () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Make sure this method isn't working if there is no package enqueued
if (!$this->isPackageEnqueued()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
* Now there are for sure packages to deliver, so start with the first
* one.
*/
- $packageData = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
+ $packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
// Declare the raw package data for delivery
- $this->declareRawPackageData($packageData);
+ $this->declareRawPackageData($packageInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function processDeclaredPackage () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No package has been declared, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package has been declared, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
} catch (UnexpectedStateException $e) {
// The state is not excepected (shall be 'connected')
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
// Mark the package with status failed
$this->changePackageStatus($packageInstance, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED);
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function sendWaitingPackage () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Sanity check if we have packages waiting for delivery
if (!$this->isPackageWaitingForDelivery()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
return;
} // END - if
$this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING);
} catch (InvalidSocketException $e) {
// Output exception message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package was not delivered: ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package was not delivered: ' . $e->getMessage());
// Mark package as failed
$this->changePackageStatus($packageInstance, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED);
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
/**
*/
public function sendEncodedData () {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Make sure there is pending encoded data
assert($this->isEncodedDataPending());
$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = NULL;
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
// And deliver it
if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) {
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
// If there was an error, don't continue here
if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) {
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
///////////////////////////////////////////////////////////////////////////
*/
private function isRawDataPending () {
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
// Just return whether the stack is not empty
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
// Return the status
return $isPending;
*/
public function isNewRawDataPending () {
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
// Visit the pool. This monitors the pool for incoming raw data.
$this->getListenerPoolInstance()->accept($this->getVisitorInstance());
$hasArrived = $this->isRawDataPending();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
// Return the status
return $hasArrived;
*/
if (!$this->isRawDataPending()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
// Very noisy debug message:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
// "Pop" the next entry (the same array again) from the stack
$packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
* only want to handle unhandled packages here.
*/
// Remove the last chunk SEPARATOR (because there is no need for it)
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $packageInstance->getErrorCode() . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: errorCode=' . $packageInstance->getErrorCode() . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
if (substr($packageInstance->getRawData(), -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// It is there and should be removed
$packageInstance->setRawData(substr($packageInstance->getRawData(), 0, -1));
} // END - if
// This package is "handled" and can be pushed on the next stack
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageInstance->getRawData()) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing ' . strlen($packageInstance->getRawData()) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $packageInstance);
}
$packageInstance = $handlerInstance->getNextRawData();
// Very noisy debug message:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($packageInstance) . ']=' . print_r($packageInstance, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedData[' . gettype($packageInstance) . ']=' . print_r($packageInstance, TRUE));
// And push it on our stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $packageInstance);
*/
public function handleAssemblerPendingData () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handlePendingData() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Calling this->getAssemblerInstance()->handlePendingData() ...');
// Handle it
$this->getAssemblerInstance()->handlePendingData();
*/
public function handleMultipleMessages () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handleMultipleMessages() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Calling this->getAssemblerInstance()->handleMultipleMessages() ...');
// Handle it
$this->getAssemblerInstance()->handleMultipleMessages();
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED);
// ... and push it on the 'chunked' stacker
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[HandleableRawData::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing ' . strlen($packageContent[HandleableRawData::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent);
}
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
// Visit the package
$visitorInstance->visitNetworkPackageHandler($this);
$this->getAssemblerInstance()->accept($visitorInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
}
/**
$this->initStacks(TRUE);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All stacker have been re-initialized.');
}
/**
*/
public function removeFirstFailedPackage () {
// Get the package again
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED);
// Is the package status 'failed'?
$this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: 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)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawPackageContent()=%d - CALLED!', strlen($rawPackageContent)));
$decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedArray=' . print_r($decodedArray, TRUE));
// Assert on count (should be always 3)
assert(count($decodedArray) == self::DECODED_DATA_ARRAY_SIZE);
$packageInstance->setPackageContent($decodedArray[self::INDEX_PACKAGE_CONTENT]);
$packageInstance->setStatus(self::PACKAGE_STATUS_DECODED);
$packageInstance->setContentHash($decodedArray[self::INDEX_PACKAGE_HASH]);
- $packageInstance->setPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]);
+ $packageInstance->setSenderPrivateKeyHash($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()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - EXIT!', $packageInstance->__toString()));
return $packageInstance;
}
* details of the array elements, see comments for constant
* PACKAGE_MASK.
*/
- $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $packageInstance->getContent());
+ $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $packageInstance->getPackageContent());
// Assert on array count for a very basic validation
assert(count($decodedContent) == self::PACKAGE_CONTENT_ARRAY_SIZE);
// Hash from decoded raw data
self::PACKAGE_CONTENT_HASH => $packageInstance->getHash(),
// Hash of private key
- self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $packageInstance->getPrivateKeyHash()
+ self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $packageInstance->getSenderPrivateKeyHash()
);
// Is the checksum valid?
$messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageArray=' . print_r($messageArray, TRUE));
// Create a handler instance from given message type
$handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
*/
public function feedHashToMiner (array $messageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: messageData()=%d - CALLED!', count($messageData)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageData()=%d - CALLED!', count($messageData)));
// Is the feature enabled?
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
unset($messageData[self::MESSAGE_ARRAY_DATA]);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE));
// Resolve session id ('sender' is a session id) into node id
$nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]);