]> git.mxchange.org Git - hub.git/commitdiff
Added/renamed miner classes:
authorRoland Haeder <roland@mxchange.org>
Mon, 12 May 2014 19:20:50 +0000 (21:20 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 12 May 2014 19:20:50 +0000 (21:20 +0200)
- Added communicator class for miner->node communication. This allows the miner
  to claim found blocks and ask the network for more.
- Moved some miner tasks in sub directories

Signed-off-by: Roland Haeder <roland@mxchange.org>
13 files changed:
application/hub/main/communicator/miner/.htaccess [new file with mode: 0644]
application/hub/main/communicator/miner/class_MinerNodeCommunicator.php [new file with mode: 0644]
application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php
application/hub/main/tasks/miner/block_fetcher/.htaccess [new file with mode: 0644]
application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php [new file with mode: 0644]
application/hub/main/tasks/miner/block_producer/.htaccess [new file with mode: 0644]
application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php [new file with mode: 0644]
application/hub/main/tasks/miner/class_ [deleted file]
application/hub/main/tasks/miner/class_Miner [new file with mode: 0644]
application/hub/main/tasks/miner/class_MinerBlockFetcherTask.php [deleted file]
application/hub/main/tasks/miner/class_MinerTestGenesisBlockProducerTask.php [deleted file]
application/hub/main/tasks/miner/communicator/.htaccess [new file with mode: 0644]
application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php [new file with mode: 0644]

diff --git a/application/hub/main/communicator/miner/.htaccess b/application/hub/main/communicator/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/communicator/miner/class_MinerNodeCommunicator.php b/application/hub/main/communicator/miner/class_MinerNodeCommunicator.php
new file mode 100644 (file)
index 0000000..5ffb67c
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A miner->node communicator class
+ *
+ * @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 MinerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $communicatorInstance           An instance of a Communicator class
+        */
+       public final static function createMinerNodeCommunicator () {
+               // Get new instance
+               $communicatorInstance = new MinerNodeCommunicator();
+
+               // Return the prepared instance
+               return $communicatorInstance;
+       }
+}
+
+// [EOF]
+?>
index f8eb6deb4e25648dea3bc28e65f5e68176dd6ead..fefaf3c1e0ca4f19010b5e85785ada3714765da3 100644 (file)
@@ -75,6 +75,14 @@ class MinerTaskHandlerInitializerFilter extends BaseMinerFilter implements Filte
                $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_test_genesis_block_producer_task_class');
                $handlerInstance->registerTask('miner_test_genesis_block_producer', $taskInstance);
 
+               /*
+                * 3) A task for communicating into the locally running 'hub' node.
+                * This rask will check for new blocks on the mining network and
+                * tries to claim found blocks.
+                */
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_node_communicator_task_class');
+               $handlerInstance->registerTask('miner_node_communicator', $taskInstance);
+
                // Put the task handler in registry
                Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
        }
diff --git a/application/hub/main/tasks/miner/block_fetcher/.htaccess b/application/hub/main/tasks/miner/block_fetcher/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php b/application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php
new file mode 100644 (file)
index 0000000..21ed537
--- /dev/null
@@ -0,0 +1,80 @@
+<?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]
+?>
diff --git a/application/hub/main/tasks/miner/block_producer/.htaccess b/application/hub/main/tasks/miner/block_producer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php b/application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php
new file mode 100644 (file)
index 0000000..8963ae3
--- /dev/null
@@ -0,0 +1,80 @@
+<?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]
+?>
diff --git a/application/hub/main/tasks/miner/class_ b/application/hub/main/tasks/miner/class_
deleted file mode 100644 (file)
index 98281cc..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?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]
-?>
diff --git a/application/hub/main/tasks/miner/class_Miner b/application/hub/main/tasks/miner/class_Miner
new file mode 100644 (file)
index 0000000..98281cc
--- /dev/null
@@ -0,0 +1,72 @@
+<?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]
+?>
diff --git a/application/hub/main/tasks/miner/class_MinerBlockFetcherTask.php b/application/hub/main/tasks/miner/class_MinerBlockFetcherTask.php
deleted file mode 100644 (file)
index 21ed537..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?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]
-?>
diff --git a/application/hub/main/tasks/miner/class_MinerTestGenesisBlockProducerTask.php b/application/hub/main/tasks/miner/class_MinerTestGenesisBlockProducerTask.php
deleted file mode 100644 (file)
index 8963ae3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?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]
-?>
diff --git a/application/hub/main/tasks/miner/communicator/.htaccess b/application/hub/main/tasks/miner/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php b/application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php
new file mode 100644 (file)
index 0000000..1ab7086
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * A MinerCommunicator 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 MinerNodeCommunicatorTask 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 createMinerNodeCommunicatorTask () {
+               // Get new instance
+               $taskInstance = new MinerNodeCommunicatorTask();
+
+               // 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
+        */
+       public function executeTask () {
+               // Get the communicator instance
+               $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('miner_node_communicator_class', 'node');
+
+               // 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 communicator instance for generating some test units
+               $stateInstance->executeState($communicatorInstance);
+       }
+}
+
+// [EOF]
+?>