]> git.mxchange.org Git - hub.git/commitdiff
'scrypt' is better now a "feature" which needs to be tested and enabled in a pre...
authorRoland Haeder <roland@mxchange.org>
Tue, 26 May 2015 22:21:12 +0000 (00:21 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 26 May 2015 22:22:43 +0000 (00:22 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/init.php
application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php
application/hub/main/filter/node/class_NodePhpRequirementsFilter.php
application/hub/main/package/class_NetworkPackage.php
core

index 548d5172ed4c5ba112e3357e7699d5736079ddc4..8699bacb7325fb13047c34e8bb0420bd571102fb 100644 (file)
@@ -37,5 +37,8 @@ require($cfg->getConfigEntry('base_path') . 'inc/database.php');
 // 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]
 ?>
index 8e3286dd02c720dd957ed9358f9c614e7e54328b..d75c2a05a510fdcb50f29d8e41b8fac4202c0ee5 100644 (file)
@@ -66,6 +66,16 @@ class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable {
                        $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
index c273029190917a86b439bed5a7bab71c05690915..c63220ea0611df74e392b7247b9a3470c598006f 100644 (file)
@@ -64,7 +64,17 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable {
                        // 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) {
index de863f1213c7a1a4fdf56664ee62850b521f5be6..c0e01cffba2abb5341e3db43d29a81ec9aae6ba7 100644 (file)
@@ -653,9 +653,15 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @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,
@@ -680,6 +686,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @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));
@@ -1414,6 +1426,15 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @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]));
diff --git a/core b/core
index 0ae3d7b0ff8ec700c174130c886eb2f9467022f0..4e6776af7c45da16f4bd7cfbab786c9c77179e01 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 0ae3d7b0ff8ec700c174130c886eb2f9467022f0
+Subproject commit 4e6776af7c45da16f4bd7cfbab786c9c77179e01