// Get own internal address and set it in config
$cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress());
+// By default scrypt is assumed (and later tested) NOT being there
+$cfg->setConfigEntry('extension_scrypt_loaded', FALSE);
+
// [EOF]
?>
$checksFailed++;
} // END -if
+ // If scrypt() is not found (ext-scrypt) then the "HubCoins reward" is not working
+ if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) {
+ // Mark it as working
+ self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "HubCoin reward" feature enabled.');
+ $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE);
+ } else {
+ // Not working (not all have ext-scrypt installed
+ self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "HubCoin reward" feature disabled.');
+ }
+
// Are all tests passed?
if ($checkPassed === FALSE) {
// Throw an exception
// Test failed
$checkPassed = FALSE;
$checksFailed++;
- } // END -if
+ } // END - if
+
+ // If scrypt() is not found (ext-scrypt) then the "HubCoins reward" is not working
+ if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) {
+ // Mark it as working
+ self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "HubCoin reward" feature enabled.');
+ $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE);
+ } else {
+ // Not working (not all have ext-scrypt installed
+ self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "HubCoin reward" feature disabled.');
+ }
// Are all tests passed?
if ($checkPassed === FALSE) {
*
* @param $content Raw package data
* @param $senderId Sender id to generate a hash for
- * @return $hash Hash as hex-encoded string
+ * @return $hash Hash as hex-encoded string
*/
private function generatePackageHash ($content, $senderId) {
+ // Is the feature enabled?
+ if ($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === FALSE) {
+ // Feature is not enabled
+ return NULL;
+ } // END - if
+
// Fake array
$data = array(
self::PACKAGE_CONTENT_SENDER => $senderId,
* @todo Unfinished area, hashes are currently NOT fully supported
*/
private function isPackageHashValid (array $decodedArray) {
+ // Is the feature enabled?
+ if ($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === FALSE) {
+ // Feature is not enabled, so hashes are always valid
+ return TRUE;
+ } // END - if
+
// Check validity
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',decodedArray=' . print_r($decodedArray, TRUE));
//* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
* @todo ~10% done?
*/
public function feedHashToMiner (array $messageData) {
+ // Is the feature enabled?
+ if ($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === FALSE) {
+ /*
+ * Feature is not enabled, don't feed the hash to the miner as it
+ *may be invalid.
+ */
+ return;
+ } // END - if
+
// Make sure the required elements are there
assert(isset($messageData[self::MESSAGE_ARRAY_SENDER]));
assert(isset($messageData[self::MESSAGE_ARRAY_HASH]));