From: Roland Haeder Date: Sat, 25 Apr 2015 22:49:23 +0000 (+0200) Subject: Fixed a lot stuff for cruncher (missing methods, etc.) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86642f37458f91f78f50b5c7f063e737a5c478ce;p=hub.git Fixed a lot stuff for cruncher (missing methods, etc.) Signed-off-by: Roland Haeder --- diff --git a/application/hub/config.php b/application/hub/config.php index 1a8e5fa6b..8c9d47e7b 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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'); diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php index e3264277f..507d4855d 100644 --- a/application/hub/main/class_BaseHubSystem.php +++ b/application/hub/main/class_BaseHubSystem.php @@ -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 * diff --git a/application/hub/main/cruncher/class_BaseHubCruncher.php b/application/hub/main/cruncher/class_BaseHubCruncher.php index f86c9b978..76feae5d2 100644 --- a/application/hub/main/cruncher/class_BaseHubCruncher.php +++ b/application/hub/main/cruncher/class_BaseHubCruncher.php @@ -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'); } /** diff --git a/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php b/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php index dfd3be2ba..8701aa589 100644 --- a/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php +++ b/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php @@ -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() . '.'); diff --git a/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php b/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php index ff42f7f04..ea7432ce8 100644 --- a/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php +++ b/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php @@ -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); } } diff --git a/application/hub/main/miner/class_BaseHubMiner.php b/application/hub/main/miner/class_BaseHubMiner.php index 13473eb73..eee201c95 100644 --- a/application/hub/main/miner/class_BaseHubMiner.php +++ b/application/hub/main/miner/class_BaseHubMiner.php @@ -68,7 +68,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { */ private function initMiner () { // Init the state - MinerStateFactory::createMinerStateInstanceByName('init', $this); + MinerStateFactory::createMinerStateInstanceByName('init'); } /** diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 6b1b0a33f..f82d4380d 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -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'); } /** diff --git a/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php b/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php index e18cdf4a2..4850d5e5d 100644 --- a/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php +++ b/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php @@ -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 * diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php index 2e0a0a1bc..4014b5f79 100644 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -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] diff --git a/application/hub/main/states/cruncher/init/class_CruncherInitState.php b/application/hub/main/states/cruncher/init/class_CruncherInitState.php index bccf3de5d..8c1938590 100644 --- a/application/hub/main/states/cruncher/init/class_CruncherInitState.php +++ b/application/hub/main/states/cruncher/init/class_CruncherInitState.php @@ -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'); } } diff --git a/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php b/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php index c9675022f..a5d2f15de 100644 --- a/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php +++ b/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php @@ -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; } diff --git a/application/hub/main/states/miner/booting/class_MinerBootingState.php b/application/hub/main/states/miner/booting/class_MinerBootingState.php index 5a29b1539..476cd4968 100644 --- a/application/hub/main/states/miner/booting/class_MinerBootingState.php +++ b/application/hub/main/states/miner/booting/class_MinerBootingState.php @@ -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; } diff --git a/application/hub/main/states/miner/init/class_MinerInitState.php b/application/hub/main/states/miner/init/class_MinerInitState.php index c8694a15c..1b687ebd5 100644 --- a/application/hub/main/states/miner/init/class_MinerInitState.php +++ b/application/hub/main/states/miner/init/class_MinerInitState.php @@ -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'); } } diff --git a/application/hub/main/states/miner/virgin/class_MinerVirginState.php b/application/hub/main/states/miner/virgin/class_MinerVirginState.php index 01450614c..40340a67d 100644 --- a/application/hub/main/states/miner/virgin/class_MinerVirginState.php +++ b/application/hub/main/states/miner/virgin/class_MinerVirginState.php @@ -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 17594a08b..e20cc950e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 17594a08ba68250b4693631ad6fab0f76c885d56 +Subproject commit e20cc950eac0ee7e24ad3ac67f5479b7f482bd8e