// CFG: MINER-INIT-STATE-CLASS
$cfg->setConfigEntry('miner_init_state_class', 'MinerInitState');
+// CFG: MINER-BLOCK-FETCHER-TASK-CLASS
+$cfg->setConfigEntry('miner_block_fetcher_task_class', 'MinerBlockFetcherTask');
+
+// CFG: TASK-MINER-BLOCK-FETCHER-STARTUP-DELAY
+$cfg->setConfigEntry('task_miner_block_fetcher_startup_delay', 1000);
+
+// CFG: TASK-MINER-BLOCK-FETCHER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_miner_block_fetcher_interval_delay', 10);
+
+// CFG: TASK--FETCHER-MAX-RUNS
+$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: TASK-MINER-TEST-GENESIS-BLOCK-PRODUCER-STARTUP-DELAY
+$cfg->setConfigEntry('task_miner_test_genesis_block_producer_startup_delay', 500);
+
+// CFG: TASK-MINER-TEST-GENESIS-BLOCK-PRODUCER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_miner_test_genesis_block_producer_interval_delay', 1000*60*60);
+
+// CFG: TASK-MINER-TEST-GENESIC-BLOCK-PRODUCER-MAX-RUNS
+$cfg->setConfigEntry('task_miner_test_genesis_block_producer_max_runs', 1);
+
+// CFG: MINER-TEST-GENESIS-BLOCK-PRODUCER-CLASS
+$cfg->setConfigEntry('miner_test_genesis_block_producer_class', 'MinerTestGenesisBlockProducer');
+
///////////////////////////////////////////////////////////////////////////////
// Cruncher configuration
///////////////////////////////////////////////////////////////////////////////
// CFG: CRUNCHER-WORK-UNIT-FETCHER-TASK-CLASS
$cfg->setConfigEntry('cruncher_work_unit_fetcher_task_class', 'CruncherWorkUnitFetcherTask');
-// CFG: CRUNCHER-TEST-UNIT-PRODUCER-TASK-CLASS
-$cfg->setConfigEntry('cruncher_test_unit_producer_task_class', 'CruncherTestUnitProducerTask');
-
-// CFG: CRUNCHER-KEY-PRODUCER-TASK-CLASS
-$cfg->setConfigEntry('cruncher_key_producer_task_class', 'CruncherKeyProducerTask');
-
// CFG: TASK-CRUNCHER-WORK-UNIT-FETCHER-STARTUP-DELAY
$cfg->setConfigEntry('task_cruncher_work_unit_fetcher_startup_delay', 1000);
// CFG: TASK-CRUNCHER-WORK-UNIT-FETCHER-MAX-RUNS
$cfg->setConfigEntry('task_cruncher_work_unit_fetcher_max_runs', 0);
+// CFG: CRUNCHER-TEST-UNIT-PRODUCER-TASK-CLASS
+$cfg->setConfigEntry('cruncher_test_unit_producer_task_class', 'CruncherTestUnitProducerTask');
+
// CFG: TASK-CRUNCHER-TEST-UNIT-PRODUCER-STARTUP-DELAY
$cfg->setConfigEntry('task_cruncher_test_unit_producer_startup_delay', 500);
// CFG: TASK-CRUNCHER-TEST-UNIT-PRODUCER-MAX-RUNS
$cfg->setConfigEntry('task_cruncher_test_unit_producer_max_runs', 0);
+// CFG: CRUNCHER-KEY-PRODUCER-TASK-CLASS
+$cfg->setConfigEntry('cruncher_key_producer_task_class', 'CruncherKeyProducerTask');
+
// CFG: TASK-CRUNCHER-KEY-PRODUCER-STARTUP-DELAY
$cfg->setConfigEntry('task_cruncher_key_producer_startup_delay', 750);
// Register all tasks:
//
- // 1) A task for ...
- //$taskInstance = ObjectFactory::createObjectByConfiguredName('miner_???_task_class');
- //$handlerInstance->registerTask('miner_???', $taskInstance);
+ // 1) A task for fetching blocks from the network
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_block_fetcher_task_class');
+ $handlerInstance->registerTask('miner_block_fetcher', $taskInstance);
+
+ /*
+ * 2) A task for generating a test "genesis" block. This "block"
+ * consists of several hashes of famous phrases or "catch lines" from
+ * free-software authors.
+ */
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_test_genesis_block_producer_task_class');
+ $handlerInstance->registerTask('miner_test_genesis_block_producer', $taskInstance);
// Put the task handler in registry
Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A MinerTestGenesisBlock producer class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class MinerTestGenesisBlockProducer extends BaseUnitProducer implements UnitProducer, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $producerInstance An instance of a Producer class
+ */
+ public final static function createMinerTestGenesisBlockProducer () {
+ // Get new instance
+ $producerInstance = new MinerTestGenesisBlockProducer();
+
+ // Return the prepared instance
+ return $producerInstance;
+ }
+
+ /**
+ * Initializes the producer. This method satisfies the abstract BaseProducer
+ * class.
+ *
+ * @return void
+ * @todo 0% done
+ */
+ protected function initProducer () {
+ $this->partialStub('Please implement this method.');
+ }
+
+ /**
+ * Prepares the produces of some test units and pushes them onto the queue
+ *
+ * @param $stateInstance An instance of a Stateable instance
+ * @return void
+ * @todo 0% done
+ */
+ public function prepareUnitProduction (Stateable $stateInstance) {
+ $this->partialStub('Please implement this method, stateInstance=' . $stateInstance->__toString());
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general BlockProducer class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2014 Miner Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseBlockProducer extends BaseProducer {
+ /**
+ * Block status
+ */
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? task for miners
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2014 Miner Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Miner???Task extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createMiner???Task () {
+ // Get new instance
+ $taskInstance = new Miner???Task();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo 0%
+ */
+ public function executeTask () {
+ $this->partialStub('Unimplemented task.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A BlockFetcher task for miners which asks the network for new blocks and
+ * starts the "block chain" fetching if no block has been fetched so far.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2011 - 2014 Miner Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class MinerBlockFetcherTask extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Taskable/Visitable class
+ */
+ public final static function createMinerBlockFetcherTask () {
+ // Get new instance
+ $taskInstance = new MinerBlockFetcherTask();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ public function executeTask () {
+ /*
+ * Get the miner instance and call a method which should check if
+ * the in-buffer is going to depleted. If so, new WUs are fetched from
+ * network or (if enabled in config) a random test WU is being
+ * generated. This test WU is for developing only or, if you like, to
+ * test your miner loop.
+ *
+ * Please report any bugs you encounter to me.
+ */
+ Registry::getRegistry()->getInstance('miner')->doSearchForBlocks();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A TestGenesisBlockProducer task for miners
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2014 Miner Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class MinerTestGenesisBlockProducerTask extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Taskable/Visitable class
+ */
+ public final static function createMinerTestGenesisBlockProducerTask () {
+ // Get new instance
+ $taskInstance = new MinerTestGenesisBlockProducerTask();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visitor
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ public function executeTask () {
+ // Get the producer instance
+ $producerInstance = ProducerFactory::createProducerInstance('miner_test_genesis_block_producer_class', 'test_unit');
+
+ // Get the current miner state from registry
+ $stateInstance = Registry::getRegistry()->getInstance('miner')->getStateInstance();
+
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
+
+ // We can now invoke that state instance and pass our producer instance for generating some test units
+ $stateInstance->executeState($producerInstance);
+ }
+}
+
+// [EOF]
+?>