From 9bec7dd3882bafac85b6897e1ab39ba91c77f185 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 4 Nov 2020 14:55:24 +0100 Subject: [PATCH] Continued: - added a lot namespaces to classes and configuration entries - added "import" lines - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../classes/blocks/miner/class_HashBlock.php | 11 ++++-- .../hub/classes/class_BaseHubSystem.php | 25 ++++++++++++ .../miner/class_MinerInitializationFilter.php | 4 +- .../miner/chash/class_HubCoinMiner.php | 3 ++ .../hub/classes/miner/class_BaseHubMiner.php | 3 ++ .../classes/producer/class_BaseProducer.php | 1 + .../cruncher/class_BaseKeyProducer.php | 6 +++ .../cruncher/class_BaseUnitProducer.php | 6 +++ .../keys/class_CruncherKeyProducer.php | 3 ++ .../class_CruncherTestUnitProducer.php | 3 ++ .../class_MinerRealGenesisBlockProducer.php | 5 +++ .../class_MinerTestGenesisBlockProducer.php | 14 +++++++ .../miner/class_BaseBlockProducer.php | 6 +++ .../miner/booting/class_MinerBootingState.php | 3 -- .../states/miner/class_BaseMinerState.php | 6 ++- .../miner/init/class_MinerInitState.php | 3 ++ .../class_CruncherKeyProducerTask.php | 2 + .../class_CruncherTestUnitProducerTask.php | 2 + ...lass_MinerRealGenesisBlockProducerTask.php | 3 +- ...lass_MinerTestGenesisBlockProducerTask.php | 4 +- application/hub/config.php | 39 ++++++++++--------- .../hub/interfaces/blocks/class_Minable.php | 3 -- .../interfaces/miner/class_MinerHelper.php | 5 +-- .../producer/block/class_BlockProducer.php | 3 ++ .../interfaces/producer/class_Producer.php | 3 -- core | 2 +- 26 files changed, 129 insertions(+), 39 deletions(-) diff --git a/application/hub/classes/blocks/miner/class_HashBlock.php b/application/hub/classes/blocks/miner/class_HashBlock.php index 315423a4d..12948b67e 100644 --- a/application/hub/classes/blocks/miner/class_HashBlock.php +++ b/application/hub/classes/blocks/miner/class_HashBlock.php @@ -1,4 +1,11 @@ +} diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 098b0bb8a..40a576dd3 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Information\ShareableInfo; use Org\Shipsimu\Hub\Listener\BaseListener; use Org\Shipsimu\Hub\Listener\Listenable; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +use Org\Shipsimu\Hub\Miner\Minable; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\Fragmentable; @@ -131,6 +132,11 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ private $packageInstance = NULL; + /** + * A Minable instance + */ + private $minableInstance = NULL; + /** * Name of used protocol */ @@ -501,4 +507,23 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface return $this->packageInstance; } + /** + * Setter for Minable instance + * + * @param $minableInstance A Minable instance + * @return void + */ + protected final function setMinableInstance (Minable $minableInstance) { + $this->minableInstance = $minableInstance; + } + + /** + * Getter for minable instance + * + * @return $minableInstance A Minable instance + */ + protected final function getMinableInstance () { + return $this->minableInstance; + } + } diff --git a/application/hub/classes/filter/miner/class_MinerInitializationFilter.php b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php index db684702b..74f7d3b60 100644 --- a/application/hub/classes/filter/miner/class_MinerInitializationFilter.php +++ b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php @@ -80,12 +80,12 @@ class MinerInitializationFilter extends BaseMinerFilter implements Filterable { } // Now convert the miner-mode in a class name - $className = 'Hub' . self::convertToClassName($minerMode) . 'Miner'; + $configEntry = sprintf('hub_%s_miner_mode_class', $minerMode); // And try to instance it try { // Get an instance - $minerInstance = ObjectFactory::createObjectByName($className); + $minerInstance = ObjectFactory::createObjectByConfiguredName($configEntry); // Get a registry $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); diff --git a/application/hub/classes/miner/chash/class_HubCoinMiner.php b/application/hub/classes/miner/chash/class_HubCoinMiner.php index ab24c45ef..cd4f7af0a 100644 --- a/application/hub/classes/miner/chash/class_HubCoinMiner.php +++ b/application/hub/classes/miner/chash/class_HubCoinMiner.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\Miner; +// Import application-specific stuff +use Org\Shipsimu\Hub\Helper\Miner\MinerHelper; + // Import framework stuff use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php index d6b92bf53..32a8d2809 100644 --- a/application/hub/classes/miner/class_BaseHubMiner.php +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -3,7 +3,10 @@ namespace Org\Shipsimu\Hub\Miner; // Import application-specific stuff +use Org\Shipsimu\Hub\Factory\State\Miner\MinerStateFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; +use Org\Shipsimu\Hub\Helper\Miner\MinerHelper; +use Org\Shipsimu\Hub\Producer\Block\BlockProducer; // Import framework stuff use Org\Mxchange\CoreFramework\Database\Updateable; diff --git a/application/hub/classes/producer/class_BaseProducer.php b/application/hub/classes/producer/class_BaseProducer.php index a37da8276..a12b53714 100644 --- a/application/hub/classes/producer/class_BaseProducer.php +++ b/application/hub/classes/producer/class_BaseProducer.php @@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; +use Org\Mxchange\CoreFramework\Stacker\Stackable; /** * A general Producer class diff --git a/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php b/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php index 1dd01f4fd..0a6d7354b 100644 --- a/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php +++ b/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php @@ -1,4 +1,10 @@ debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Return the prepared instance return $stateInstance; } diff --git a/application/hub/classes/states/miner/class_BaseMinerState.php b/application/hub/classes/states/miner/class_BaseMinerState.php index b5779ad02..5ac79417a 100644 --- a/application/hub/classes/states/miner/class_BaseMinerState.php +++ b/application/hub/classes/states/miner/class_BaseMinerState.php @@ -1,6 +1,10 @@ setConfigEntry('hub_console_cmd_miner_resolver_class', 'Org\Shipsimu\Hub\R $cfg->setConfigEntry('miner_php_requirements_filter_class', 'Org\Shipsimu\Hub\Miner\Filter\Requirements\MinerPhpRequirementsFilter'); // CFG: MINER-INITIALIZER-FILTER -$cfg->setConfigEntry('miner_initializer_filter_class', 'MinerInitializationFilter'); +$cfg->setConfigEntry('miner_initializer_filter_class', 'Org\Shipsimu\Hub\Miner\Filter\Initialization\MinerInitializationFilter'); // CFG: MINER-WELCOME-TEASER-FILTER -$cfg->setConfigEntry('miner_welcome_teaser_filter_class', 'MinerWelcomeTeaserFilter'); +$cfg->setConfigEntry('miner_welcome_teaser_filter_class', 'Org\Shipsimu\Hub\Miner\Filter\WelcomeTeaser\MinerWelcomeTeaserFilter'); // CFG: MINER-BOOTSTRAP-TASK-HANDLER-INITIALIZER-FILTER -$cfg->setConfigEntry('miner_bootstrap_task_handler_initializer_filter_class', 'MinerTaskHandlerInitializerFilter'); +$cfg->setConfigEntry('miner_bootstrap_task_handler_initializer_filter_class', 'Org\Shipsimu\Hub\Filter\Initializer\Miner\Handler\Task\MinerTaskHandlerInitializerFilter'); // CFG: CRUNCHER-BOOTSTRAP-EXTRA-BOOTSTRAPPING-FILTER -$cfg->setConfigEntry('miner_bootstrap_extra_bootstrapping_filter_class', 'MinerBootstrapExtraBootstrappingFilter'); +$cfg->setConfigEntry('miner_bootstrap_extra_bootstrapping_filter_class', 'Org\Shipsimu\Hub\Filter\Bootstrap\Miner\Extra\MinerBootstrapExtraBootstrappingFilter'); // CFG: MINHER-BOOTSTRAP-BUFFER-QUEUE-INITIALIZER-FILTER -$cfg->setConfigEntry('miner_bootstrap_buffer_queue_initializer_filter_class', 'MinerBootstrapBufferQueueInitializerFilter'); +$cfg->setConfigEntry('miner_bootstrap_buffer_queue_initializer_filter_class', 'Org\Shipsimu\Hub\Filter\Bootstrap\Miner\Queue\MinerBootstrapBufferQueueInitializerFilter'); // CFG: MINER-BOOTSTRAP-GENERIC-ACTIVATION-FILTER -$cfg->setConfigEntry('miner_bootstrap_generic_activation_filter_class', 'MinerBootstrapGenericActivationFilter'); +$cfg->setConfigEntry('miner_bootstrap_generic_activation_filter_class', 'Org\Shipsimu\Hub\Filter\Bootstrap\Miner\Activation\MinerBootstrapGenericActivationFilter'); // CFG: MINER-SHUTDOWN-FILTER -$cfg->setConfigEntry('miner_shutdown_filter_class', 'MinerShutdownFilter'); +$cfg->setConfigEntry('miner_shutdown_filter_class', 'Org\Shipsimu\Hub\Filter\Shutdown\Miner\MinerShutdownFilter'); // CFG: MINER-INIT-STATE-CLASS -$cfg->setConfigEntry('miner_init_state_class', 'MinerInitState'); +$cfg->setConfigEntry('miner_init_state_class', 'Org\Shipsimu\Hub\State\Miner\MinerInitState'); // CFG: MINER-BOOTING-STATE-CLASS -$cfg->setConfigEntry('miner_booting_state_class', 'MinerBootingState'); +$cfg->setConfigEntry('miner_booting_state_class', 'Org\Shipsimu\Hub\State\Miner\MinerBootingState'); // CFG: MINER-BLOCK-FETCHER-TASK-CLASS -$cfg->setConfigEntry('miner_block_fetcher_task_class', 'MinerBlockFetcherTask'); +$cfg->setConfigEntry('miner_block_fetcher_task_class', 'Org\Shipsimu\Hub\Miner\Task\Fetcher\Block\MinerBlockFetcherTask'); // CFG: TASK-MINER-BLOCK-FETCHER-STARTUP-DELAY $cfg->setConfigEntry('task_miner_block_fetcher_startup_delay', 1000); @@ -1008,7 +1008,7 @@ $cfg->setConfigEntry('task_miner_block_fetcher_interval_delay', 1000); $cfg->setConfigEntry('task_miner_block_fetcher_max_runs', 0); // CFG: MINER-TEST-GENESIS-BLOCK-PRODUCER-TASK-CLASS -$cfg->setConfigEntry('miner_test_genesis_block_producer_task_class', 'MinerTestGenesisBlockProducerTask'); +$cfg->setConfigEntry('miner_test_genesis_block_producer_task_class', 'Org\Shipsimu\Hub\Miner\Task\Producer\Block\Genesis\MinerTestGenesisBlockProducerTask'); // CFG: TASK-MINER-TEST-GENESIS-BLOCK-PRODUCER-STARTUP-DELAY $cfg->setConfigEntry('task_miner_test_genesis_block_producer_startup_delay', 1000); @@ -1020,7 +1020,7 @@ $cfg->setConfigEntry('task_miner_test_genesis_block_producer_interval_delay', 10 $cfg->setConfigEntry('task_miner_test_genesis_block_producer_max_runs', 0); // CFG: MINER-REAL-GENESIS-BLOCK-PRODUCER-TASK-CLASS -$cfg->setConfigEntry('miner_real_genesis_block_producer_task_class', 'MinerRealGenesisBlockProducerTask'); +$cfg->setConfigEntry('miner_real_genesis_block_producer_task_class', 'Org\Shipsimu\Hub\Miner\Task\Producer\Block\Genesis\MinerRealGenesisBlockProducerTask'); // CFG: TASK-MINER-REAL-GENESIS-BLOCK-PRODUCER-STARTUP-DELAY $cfg->setConfigEntry('task_miner_real_genesis_block_producer_startup_delay', 500); @@ -1032,7 +1032,7 @@ $cfg->setConfigEntry('task_miner_real_genesis_block_producer_interval_delay', 10 $cfg->setConfigEntry('task_miner_real_genesis_block_producer_max_runs', 0); // CFG: MINER_NODE-COMMUNICATOR-TASK-CLASS -$cfg->setConfigEntry('miner_node_communicator_task_class', 'MinerNodeCommunicatorTask'); +$cfg->setConfigEntry('miner_node_communicator_task_class', 'Org\Shipsimu\Hub\Miner\Task\Communicator\Node\MinerNodeCommunicatorTask'); // CFG: TASK-MINER_NODE-COMMUNICATOR-STARTUP-DELAY $cfg->setConfigEntry('task_miner_node_communicator_startup_delay', 500); @@ -1044,19 +1044,22 @@ $cfg->setConfigEntry('task_miner_node_communicator_interval_delay', 250); $cfg->setConfigEntry('task_miner_node_communicator_max_runs', 0); // CFG: MINER-TEST-GENESIS-BLOCK-PRODUCER-CLASS -$cfg->setConfigEntry('miner_test_genesis_block_producer_class', 'MinerTestGenesisBlockProducer'); +$cfg->setConfigEntry('miner_test_genesis_block_producer_class', 'Org\Shipsimu\Hub\miner\Producer\Block\Genesis\MinerTestGenesisBlockProducer'); // CFG: MINER-REAL-GENESIS-BLOCK-PRODUCER-CLASS -$cfg->setConfigEntry('miner_real_genesis_block_producer_class', 'MinerRealGenesisBlockProducer'); +$cfg->setConfigEntry('miner_real_genesis_block_producer_class', 'Org\Shipsimu\Hub\Miner\Producer\Block\Genesis\MinerRealGenesisBlockProducer'); // CFG: MINER-NODE-COMMUNICATOR-CLASS -$cfg->setConfigEntry('miner_node_communicator_class', 'MinerNodeCommunicator'); +$cfg->setConfigEntry('miner_node_communicator_class', 'Org\Shipsimu\Hub\Miner\Communicator\Node\MinerNodeCommunicator'); // CFG: MINER-TEST-HASH-BLOCK-CLASS -$cfg->setConfigEntry('miner_test_hash_block_class', 'HashBlock'); +$cfg->setConfigEntry('miner_test_hash_block_class', 'Org\Shipsimu\Hub\Block\Hash\HashBlock'); // CFG: MINER-REAL-HASH-BLOCK-CLASS -$cfg->setConfigEntry('miner_real_hash_block_class', 'HashBlock'); +$cfg->setConfigEntry('miner_real_hash_block_class', 'Org\Shipsimu\Hub\Block\Hash\HashBlock'); + +// CFG: HUB-COIN-MINER-MODE-CLASS +$cfg->setConfigEntry('hub_coin_miner_mode_class', 'Org\Shipsimu\Hub\Miner\HubCoinMiner'); /////////////////////////////////////////////////////////////////////////////// // Cruncher configuration diff --git a/application/hub/interfaces/blocks/class_Minable.php b/application/hub/interfaces/blocks/class_Minable.php index eeb384b51..aa1f47617 100644 --- a/application/hub/interfaces/blocks/class_Minable.php +++ b/application/hub/interfaces/blocks/class_Minable.php @@ -30,6 +30,3 @@ use Org\Shipsimu\Hub\Generic\HubInterface; */ interface Minable extends HubInterface { } - -// [EOF] -?> diff --git a/application/hub/interfaces/miner/class_MinerHelper.php b/application/hub/interfaces/miner/class_MinerHelper.php index cb77e82fe..64f08745d 100644 --- a/application/hub/interfaces/miner/class_MinerHelper.php +++ b/application/hub/interfaces/miner/class_MinerHelper.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Helper\Miner; // Import application-specific stuff use Org\Shipsimu\Hub\Generic\HubInterface; +use Org\Shipsimu\Hub\Producer\Block\BlockProducer; // Import framework stuff use Org\Mxchange\CoreFramework\Controller\Controller; @@ -98,7 +99,5 @@ interface MinerHelper extends HubInterface { * @return void */ function blockProducerHasInitialized (BlockProducer $producerInstance); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/producer/block/class_BlockProducer.php b/application/hub/interfaces/producer/block/class_BlockProducer.php index f46d776ef..5ab499a2e 100644 --- a/application/hub/interfaces/producer/block/class_BlockProducer.php +++ b/application/hub/interfaces/producer/block/class_BlockProducer.php @@ -2,6 +2,9 @@ // Own namespace namespace Org\Shipsimu\Hub\Producer\Block; +// Import application-specific stuff +use Org\Shipsimu\Hub\Producer\Producer; + // Import framework stuff use Org\Mxchange\CoreFramework\Executor\Executor; use Org\Mxchange\CoreFramework\State\Stateable; diff --git a/application/hub/interfaces/producer/class_Producer.php b/application/hub/interfaces/producer/class_Producer.php index c0abd4f1e..004798a6a 100644 --- a/application/hub/interfaces/producer/class_Producer.php +++ b/application/hub/interfaces/producer/class_Producer.php @@ -29,6 +29,3 @@ use Org\Shipsimu\Hub\Generic\HubInterface; */ interface Producer extends HubInterface { } - -// [EOF] -?> diff --git a/core b/core index d1d4c27a2..6d6b58a10 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d1d4c27a298fb48a433ab3ee132229d88274b060 +Subproject commit 6d6b58a1042e6ad5d6277f8ff5144c95f1abd427 -- 2.39.5