]> git.mxchange.org Git - hub.git/commitdiff
Fixed a lot stuff for cruncher (missing methods, etc.)
authorRoland Haeder <roland@mxchange.org>
Sat, 25 Apr 2015 22:49:23 +0000 (00:49 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 25 Apr 2015 22:49:23 +0000 (00:49 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
15 files changed:
application/hub/config.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/cruncher/class_BaseHubCruncher.php
application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php
application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php
application/hub/main/miner/class_BaseHubMiner.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php
application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php
application/hub/main/states/cruncher/init/class_CruncherInitState.php
application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php
application/hub/main/states/miner/booting/class_MinerBootingState.php
application/hub/main/states/miner/init/class_MinerInitState.php
application/hub/main/states/miner/virgin/class_MinerVirginState.php
core

index 1a8e5fa6b749c30b5689d9999fce16a320300d65..8c9d47e7b7247c340746aa7ed6a909304ac157ba 100644 (file)
@@ -1009,7 +1009,7 @@ $cfg->setConfigEntry('cruncher_default_mode', 'mcrypt');
 $cfg->setConfigEntry('cruncher_buffer_stacker_class', 'FiFoStacker');
 
 // CFG: HUB-CONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_cruncher_resolver_class', 'HubConsoleCommandResolver');
+$cfg->setConfigEntry('hub_console_cmd_cruncher_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: CRUNCHER-PHP-REQUIREMENTS-FILTER
 $cfg->setConfigEntry('cruncher_php_requirements_filter', 'CruncherPhpRequirementsFilter');
@@ -1126,7 +1126,7 @@ $cfg->setConfigEntry('test_unit_producer_key_iterator_class', 'TestUnitKeyProduc
 $cfg->setConfigEntry('work_unit_producer_key_iterator_class', 'WorkUnitKeyProducerIterator');
 
 // CFG: TEST-UNIT-RANDOM-SECRET-KEY-LENGTH
-$cfg->setConfigEntry('test_unit_random_secret_key_length', 8*4);
+$cfg->setConfigEntry('test_unit_random_secret_key_length', 8 * 32);
 
 // CFG: TEST-UNIT-SOURCE-CLASS
 $cfg->setConfigEntry('test_unit_source_class', 'TestUnitSource');
@@ -1148,7 +1148,7 @@ $cfg->setConfigEntry('cruncher_per_unit_key_limit', 1000);
 ///////////////////////////////////////////////////////////////////////////////
 
 // CFG: HUB-CONSOLE-CMD-CHAT-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_chat_resolver_class', 'HubConsoleCommandResolver');
+$cfg->setConfigEntry('hub_console_cmd_chat_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: CHAT-PHP-REQUIREMENTS-FILTER
 $cfg->setConfigEntry('chat_php_requirements_filter', 'ChatPhpRequirementsFilter');
index e3264277f1f7407733cdb0054e13f015a8710373..507d4855d5a26b2d1948a5a537ae40efe306aff3 100644 (file)
@@ -54,16 +54,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
         */
        private $communicatorInstance = NULL;
 
-       /**
-        * An instance of a cruncher
-        */
-       private $cruncherInstance = NULL;
-
-       /**
-        * An instance of a miner
-        */
-       private $minerInstance = NULL;
-
        /**
         * A network package handler instance
         */
@@ -153,44 +143,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
                $this->communicatorInstance = $communicatorInstance;
        }
 
-       /**
-        * Getter for cruncher instance
-        *
-        * @return      $cruncherInstance       An instance of a cruncher cruncher
-        */
-       public final function getCruncherInstance () {
-               return $this->cruncherInstance;
-       }
-
-       /**
-        * Setter for cruncher instance
-        *
-        * @param       $cruncherInstance       An instance of a cruncher cruncher
-        * @return      void
-        */
-       protected final function setCruncherInstance (CruncherHelper $cruncherInstance) {
-               $this->cruncherInstance = $cruncherInstance;
-       }
-
-       /**
-        * Getter for miner instance
-        *
-        * @return      $minerInstance  An instance of a miner miner
-        */
-       public final function getMinerInstance () {
-               return $this->minerInstance;
-       }
-
-       /**
-        * Setter for miner instance
-        *
-        * @param       $minerInstance  An instance of a miner miner
-        * @return      void
-        */
-       protected final function setMinerInstance (MinerHelper $minerInstance) {
-               $this->minerInstance = $minerInstance;
-       }
-
        /**
         * Setter for network package handler instance
         *
index f86c9b978d4d610d93bc00593a1647e4979cd719..76feae5d2beebbe95c50fe5df4b9f13ac68bd018 100644 (file)
@@ -57,6 +57,9 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable {
                // Call parent constructor
                parent::__construct($className);
 
+               // Set this cruncher instance in registry
+               Registry::getRegistry()->addInstance('cruncher', $this);
+
                // Init this cruncher
                $this->initCruncher();
        }
@@ -68,7 +71,7 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable {
         */
        private function initCruncher () {
                // Init the state
-               CruncherStateFactory::createCruncherStateInstanceByName('init', $this);
+               CruncherStateFactory::createCruncherStateInstanceByName('init');
        }
 
        /**
index dfd3be2ba3cb6a477d9f16c46cb5c1c949dea0bf..8701aa589cea01ad924340e6609809668dafbfd1 100644 (file)
@@ -40,12 +40,15 @@ class CruncherStateFactory extends ObjectFactory {
         * @param       $cruncherInstance       A CruncherHelper class instance
         * @return      $stateInstance          A Stateable class instance
         */
-       public static final function createCruncherStateInstanceByName ($stateName, CruncherHelper $cruncherInstance) {
+       public static final function createCruncherStateInstanceByName ($stateName) {
                // Then construct the class' configuraton entry
                $className = 'cruncher_' . $stateName . '_state_class';
 
+               // Get cruncher instance from registry
+               $cruncherInstance = Registry::getRegistry()->getInstance('cruncher');
+
                // Get a class from that configuration entry
-               $stateInstance = self::createObjectByConfiguredName($className, array($cruncherInstance));
+               $stateInstance = self::createObjectByConfiguredName($className);
 
                // Debug message
                self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Cruncher state has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
index ff42f7f041fdfb96ee6d58617f38ba920c18a2e5..ea7432ce8414def652ee277c6fd11116e6e16228 100644 (file)
@@ -87,9 +87,6 @@ class CruncherInitializationFilter extends BaseCruncherFilter implements Filtera
                        // @TODO Can we rewrite this to app_exit() ?
                        $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']:  cruncher mode ' . $cruncherMode . ' is invalid.');
                }
-
-               // Set the cruncher instance in registry
-               Registry::getRegistry()->addInstance('cruncher', $cruncherInstance);
        }
 }
 
index 13473eb73deadcaa4a9616904cb124b8752efc4d..eee201c95d78824ebe8a04eedc8fbbd4a8969f12 100644 (file)
@@ -68,7 +68,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable {
         */
        private function initMiner () {
                // Init the state
-               MinerStateFactory::createMinerStateInstanceByName('init', $this);
+               MinerStateFactory::createMinerStateInstanceByName('init');
        }
 
        /**
index 6b1b0a33f9809b4859127f380621f906a27fb267..f82d4380d9ed3569ea7e5b7272d74e36c0de22b5 100644 (file)
@@ -95,7 +95,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         */
        private function initState() {
                // Get the state factory and create the initial state.
-               NodeStateFactory::createNodeStateInstanceByName('init', $this);
+               NodeStateFactory::createNodeStateInstanceByName('init');
        }
 
        /**
index e18cdf4a226ef592563e7ab71c339a74caed184d..4850d5e5de5efc343ac371e0e8ebb0423a1964ed 100644 (file)
@@ -64,6 +64,16 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist
        protected function initProducer () {
        }
 
+       /**
+        * Initializes the executor, whatever it does.
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initExecutor (Stateable $stateInstance) {
+               $this->partialStub('Maybe implement this method?');
+       }
+
        /**
         * Produces some keys and pushes them onto the queue
         *
index 2e0a0a1bca32dd93e46c22ddbc9beb01e35c5a3c..4014b5f79f9a369d59901b66c2531be13d9f4519 100644 (file)
@@ -104,6 +104,16 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
                        $stateInstance->encryptedMessageGenerated();
                }
        }
+
+       /**
+        * Initializes the executor, whatever it does.
+        *
+        * @return      void
+        * @todo        Maybe unfinished
+        */
+       public function initExecutor (Stateable $stateInstance) {
+               $this->partialStub('Maybe implement this method?');
+       }
 }
 
 // [EOF]
index bccf3de5da21ef7a999a003351f142da1c84067e..8c1938590e4949c01bee3ce1424105c9cfffc142 100644 (file)
@@ -38,16 +38,12 @@ class CruncherInitState extends BaseCruncherState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cruncherInstance       An instance of a CruncherHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createCruncherInitState (CruncherHelper $cruncherInstance) {
+       public final static function createCruncherInitState () {
                // Get new instance
                $stateInstance = new CruncherInitState();
 
-               // Set the cruncher instance
-               $stateInstance->setCruncherInstance($cruncherInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -71,7 +67,7 @@ class CruncherInitState extends BaseCruncherState implements Stateable {
         */
        public function encryptedMessageGenerated () {
                // Change the state now to 'virgin'
-               CruncherStateFactory::createCruncherStateInstanceByName('virgin', $this->getCruncherInstance());
+               CruncherStateFactory::createCruncherStateInstanceByName('virgin');
        }
 }
 
index c9675022fffed8b57d422c9082db6691e7dab390..a5d2f15de49b9da659c532b6ae5362785a11507d 100644 (file)
@@ -38,16 +38,12 @@ class CruncherVirginState extends BaseCruncherState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $cruncherInstance       An instance of a CruncherHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createCruncherVirginState (CruncherHelper $cruncherInstance) {
+       public final static function createCruncherVirginState () {
                // Get new instance
                $stateInstance = new CruncherVirginState();
 
-               // Set the cruncher instance
-               $stateInstance->setCruncherInstance($cruncherInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
index 5a29b1539e6637e7cdb23396c23f6ef77d7a6cce..476cd4968b9d2feaa4a4dc9d13fdab3885392ed7 100644 (file)
@@ -38,19 +38,15 @@ class MinerBootingState extends BaseMinerState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $minerInstance  An instance of a MinerHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createMinerBootingState (MinerHelper $minerInstance) {
+       public final static function createMinerBootingState () {
                // Get new instance
                $stateInstance = new MinerBootingState();
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
 
-               // Set the miner instance
-               $stateInstance->setMinerInstance($minerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
index c8694a15c20ce5ea89fb019e58a440e7f49fc8cd..1b687ebd51badcf92aef661068953bd57a69b8e4 100644 (file)
@@ -38,16 +38,12 @@ class MinerInitState extends BaseMinerState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $minerInstance  An instance of a MinerHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createMinerInitState (MinerHelper $minerInstance) {
+       public final static function createMinerInitState () {
                // Get new instance
                $stateInstance = new MinerInitState();
 
-               // Set the miner instance
-               $stateInstance->setMinerInstance($minerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -70,7 +66,7 @@ class MinerInitState extends BaseMinerState implements Stateable {
         */
        public function encryptedMessageGenerated () {
                // Change the state now to 'virgin'
-               MinerStateFactory::createMinerStateInstanceByName('virgin', $this->getMinerInstance());
+               MinerStateFactory::createMinerStateInstanceByName('virgin');
        }
 }
 
index 01450614cc2f94a61ba11cab4d15dd985e1278dd..40340a67d9dae336b58d6b2675f5c4ce38a3cf90 100644 (file)
@@ -38,16 +38,12 @@ class MinerVirginState extends BaseMinerState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $minerInstance  An instance of a MinerHelper class
         * @return      $stateInstance  An instance of a Stateable class
         */
-       public final static function createMinerVirginState (MinerHelper $minerInstance) {
+       public final static function createMinerVirginState () {
                // Get new instance
                $stateInstance = new MinerVirginState();
 
-               // Set the miner instance
-               $stateInstance->setMinerInstance($minerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
diff --git a/core b/core
index 17594a08ba68250b4693631ad6fab0f76c885d56..e20cc950eac0ee7e24ad3ac67f5479b7f482bd8e 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 17594a08ba68250b4693631ad6fab0f76c885d56
+Subproject commit e20cc950eac0ee7e24ad3ac67f5479b7f482bd8e