$dhtInstance = DhtObjectFactory::createDhtInstance('node');
// Ask DHT for session id
- $senderData = $dhtInstance->findNodeLocalBySessionId($decodedData[self::INDEX_PACKAGE_SENDER]);
+ $senderData = $dhtInstance->findNodeLocalBySessionId($decodedData[self::PACKAGE_CONTENT_SENDER]);
// Is an entry found?
if (count($senderData) > 0) {
// Make sure the requested element is there
// @TODO Wrong hash!!!!
/* DEBUG-DIE */ die('decodedData=' . print_r($decodedData, TRUE));
- assert(isset($decodedData[self::INDEX_PACKAGE_HASH]));
+ assert(isset($decodedData[self::PACKAGE_CONTENT_HASH]));
// There is no DHT entry so, accept the hash from decoded data
- return $decodedData[self::INDEX_PACKAGE_HASH];
+ return $decodedData[self::PACKAGE_CONTENT_HASH];
}
/**
private function isPackageHashValid (array $decodedArray) {
// Check validity
//* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
- $isHashValid = Scrypt::checkScrypt($decodedArray[self::INDEX_PACKAGE_SENDER] . ':' . $decodedArray[self::INDEX_PACKAGE_CONTENT] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::INDEX_PACKAGE_HASH]);
+ $isHashValid = Scrypt::checkScrypt($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_CONTENT] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]);
// Return it
//* DEBUG-DIE: */ die(__METHOD__ . ': isHashValid=' . intval($isHashValid) . ',decodedArray=' . print_r($decodedArray, TRUE));
// Assert on count (should be always 3)
assert(count($decodedArray) == self::DECODED_DATA_ARRAY_SIZE);
- // Generate the hash of comparing it
- if (!$this->isPackageHashValid($decodedArray)) {
- // Is not valid, so throw an exception here
- exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . chr(10));
- } // END - if
-
/*
* Create 'decodedData' array with all assoziative array elements.
*/
// Get it from the stacker, it is the full array with the decoded message
$decodedContent = $this->getStackInstance()->popNamed(self::STACKER_NAME_NEW_MESSAGE);
+ // Generate the hash of comparing it
+ if (!$this->isPackageHashValid($decodedContent)) {
+ // Is not valid, so throw an exception here
+ exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . chr(10));
+ } // END - if
+
// Now get a filter chain back from factory with given tags array
$chainInstance = PackageFilterChainFactory::createChainByTagsArray($decodedContent[self::PACKAGE_CONTENT_TAGS]);