]> git.mxchange.org Git - hub.git/commitdiff
Added very basic classes and config entries (duplicated from cruncher sub-project...
authorRoland Haeder <roland@mxchange.org>
Mon, 31 Mar 2014 19:32:15 +0000 (21:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 31 Mar 2014 19:32:15 +0000 (21:32 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
34 files changed:
application/hub/config.php
application/hub/interfaces/miner/.htaccess [new file with mode: 0644]
application/hub/interfaces/miner/class_MinerHelper.php [new file with mode: 0644]
application/hub/main/commands/console/class_HubConsoleMinerCommand.php [new file with mode: 0644]
application/hub/main/controller/console/class_HubConsoleMinerController.php [new file with mode: 0644]
application/hub/main/factories/states/miner/.htaccess [new file with mode: 0644]
application/hub/main/factories/states/miner/class_MinerStateFactory.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/miner/.htaccess [new file with mode: 0644]
application/hub/main/filter/bootstrap/miner/class_MinerBootstrap [new file with mode: 0644]
application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php [new file with mode: 0644]
application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php [new file with mode: 0644]
application/hub/main/filter/class_BaseMinerFilter.php [new file with mode: 0644]
application/hub/main/filter/miner/.htaccess [new file with mode: 0644]
application/hub/main/filter/miner/class_Miner [new file with mode: 0644]
application/hub/main/filter/miner/class_MinerInitializationFilter.php [new file with mode: 0644]
application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php [new file with mode: 0644]
application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php [new file with mode: 0644]
application/hub/main/filter/shutdown/miner/.htaccess [new file with mode: 0644]
application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php [new file with mode: 0644]
application/hub/main/filter/task/miner/.htaccess [new file with mode: 0644]
application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php [new file with mode: 0644]
application/hub/main/miner/.htaccess [new file with mode: 0644]
application/hub/main/miner/chash/.htaccess [new file with mode: 0644]
application/hub/main/miner/chash/class_HubChashMiner.php [new file with mode: 0644]
application/hub/main/miner/class_ [new file with mode: 0644]
application/hub/main/miner/class_BaseHubMiner.php [new file with mode: 0644]
application/hub/main/states/miner/.htaccess [new file with mode: 0644]
application/hub/main/states/miner/class_ [new file with mode: 0644]
application/hub/main/states/miner/class_BaseMinerState.php [new file with mode: 0644]
application/hub/main/states/miner/init/.htaccess [new file with mode: 0644]
application/hub/main/states/miner/init/class_MinerInitState.php [new file with mode: 0644]
application/hub/main/states/miner/virgin/.htaccess [new file with mode: 0644]
application/hub/main/states/miner/virgin/class_MinerVirginState.php [new file with mode: 0644]

index 526836593fc2fb3823ce2934d83c829069c381d7..c4fe119b554d1f454d67ac945695a3904f260850 100644 (file)
@@ -919,6 +919,46 @@ $cfg->setConfigEntry('self_recipient_class', 'SelfRecipient');
 // CFG: UPPER-RECIPIENT-CLASS
 $cfg->setConfigEntry('upper_recipient_class', 'UpperRecipient');
 
+///////////////////////////////////////////////////////////////////////////////
+//                         Miner configuration
+///////////////////////////////////////////////////////////////////////////////
+
+// CFG: MINER-DEFAULT-MODE (can be only 'chash' at the moment)
+$cfg->setConfigEntry('miner_default_mode', 'chash');
+
+// CFG: MINER-BUFFER-STACKER-CLASS
+$cfg->setConfigEntry('miner_buffer_stacker_class', 'FiFoStacker');
+
+// CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
+$cfg->setConfigEntry('hubconsole_cmd_miner_resolver_class', 'HubConsoleCommandResolver');
+
+// CFG: MINER-PHP-REQUIREMENTS-FILTER
+$cfg->setConfigEntry('miner_php_requirements_filter', 'MinerPhpRequirementsFilter');
+
+// CFG: MINER-INITIALIZER-FILTER
+$cfg->setConfigEntry('miner_initializer_filter', 'MinerInitializationFilter');
+
+// CFG: MINER-WELCOME-TEASER-FILTER
+$cfg->setConfigEntry('miner_welcome_teaser_filter', 'MinerWelcomeTeaserFilter');
+
+// CFG: MINER-BOOTSTRAP-TASK-HANDLER-INITIALIZER-FILTER
+$cfg->setConfigEntry('miner_bootstrap_task_handler_initializer_filter', 'MinerTaskHandlerInitializerFilter');
+
+// CFG: CRUNCHER-BOOTSTRAP-EXTRA-BOOTSTRAPPING-FILTER
+$cfg->setConfigEntry('miner_bootstrap_extra_bootstrapping_filter', 'MinerBootstrapExtraBootstrappingFilter');
+
+// CFG: MINHER-BOOTSTRAP-BUFFER-QUEUE-INITIALIZER-FILTER
+$cfg->setConfigEntry('miner_bootstrap_buffer_queue_initializer_filter', 'MinerBootstrapBufferQueueInitializerFilter');
+
+// CFG: MINER-BOOTSTRAP-GENERIC-ACTIVATION-FILTER
+$cfg->setConfigEntry('miner_bootstrap_generic_activation_filter', 'MinerBootstrapGenericActivationFilter');
+
+// CFG: MINER-SHUTDOWN-FILTER
+$cfg->setConfigEntry('miner_shutdown_filter', 'MinerShutdownFilter');
+
+// CFG: MINER-INIT-STATE-CLASS
+$cfg->setConfigEntry('miner_init_state_class', 'MinerInitState');
+
 ///////////////////////////////////////////////////////////////////////////////
 //                        Cruncher configuration
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/application/hub/interfaces/miner/.htaccess b/application/hub/interfaces/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/miner/class_MinerHelper.php b/application/hub/interfaces/miner/class_MinerHelper.php
new file mode 100644 (file)
index 0000000..4f1daed
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * An interface for "node-helper" classes
+ *
+ * @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
+ * @todo               We need to find a better name for this interface
+ *
+ * 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/>.
+ */
+interface MinerHelper extends FrameworkInterface {
+       /**
+        * Method to "bootstrap" the miner. This step does also apply provided
+        * command-line arguments stored in the request instance. You should now
+        * get it from calling $this->getRequestInstance().
+        *
+        * @return      void
+        */
+       function doBootstrapping ();
+
+       /**
+        * This method determines if the in-buffer is going to depleted and if so,
+        * it fetches more WUs from the network. If no WU can be fetched from the
+        * network and if enabled, a random test WU is being generated.
+        *
+        * @return      void
+        */
+       function doFetchWorkUnits ();
+
+       /**
+        * Outputs the console teaser. This should only be executed on startup or
+        * full restarts. This method generates some space around the teaser.
+        *
+        * @return      void
+        */
+       function outputConsoleTeaser ();
+
+       /**
+        * Add some miner-specific filters
+        *
+        * @param       $controllerInstance             An object of a Controller instance
+        * @param       $responseInstance               An object of a Responseable instance
+        * @return      void
+        */
+       function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance);
+
+       /**
+        * Enables/disables the miner (just sets a flag)
+        *
+        * @param       $version        Version number of this miner
+        * @return      void
+        */
+       function enableIsActive ($isActive = TRUE);
+
+       /**
+        * Determines whether the miner is active
+        *
+        * @return      $isActive       Whether the miner is active
+        */
+       function isActive ();
+
+       /**
+        * Initializes all buffer queues (mostly in/out)
+        *
+        * @return      void
+        */
+       function initBufferQueues ();
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/commands/console/class_HubConsoleMinerCommand.php b/application/hub/main/commands/console/class_HubConsoleMinerCommand.php
new file mode 100644 (file)
index 0000000..83aaf63
--- /dev/null
@@ -0,0 +1,132 @@
+<?php
+/**
+ * A command for the 'miner client' routine
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2012 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 HubConsoleMinerCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance       An instance of a command resolver class
+        * @return      $commandInstance        An instance a prepared command class
+        */
+       public static final function createHubConsoleMinerCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new HubConsoleMinerCommand();
+
+               // Set the application instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the given command with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        Try to create a MinerActivationTask or so
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get a registry and the application instance from it
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+               /*
+                * ----------------------- Bootstrapping phase ------------------------
+                * Try to bootstrap the node and pass the request instance to it for
+                * extra arguments which mostly override config entries or enable special
+                * features within the hub (none is ready at this development stage)
+                */
+               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+               $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
+               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
+
+               // Get miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Add some miner-specific filters
+               $minerInstance->addExtraMinerFilters();
+
+               // Get task handler instance
+               $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
+
+               /*
+                * ----------------------------- Main loop ----------------------------
+                * This is the main loop. Queried calls should come back here very fast
+                * so the whole application runs on nice speed. This while-loop goes
+                * until the miner is no longer active or all tasks are killed.
+                */
+               while (($minerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
+                       // Handle all tasks here
+                       $handlerInstance->handleTasks();
+               } // END - while
+
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
+       }
+
+       /**
+        * Adds extra filters to the given controller instance
+        *
+        * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
+        * @return      void
+        * @todo        Should we add some more filters?
+        */
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+               // Add pre filters
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_php_requirements_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_initializer_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_welcome_teaser_filter'));
+
+               // Add bootstrap filters
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_task_handler_initializer_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_extra_bootstrapping_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_buffer_queue_initializer_filter'));
+
+               // This is the last generic boostrap filter
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_generic_activation_filter'));
+
+               // Add shutdown filters
+               //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_task_handler_filter'));
+
+               // This is the last generic shutdown filter
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_filter'));
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/controller/console/class_HubConsoleMinerController.php b/application/hub/main/controller/console/class_HubConsoleMinerController.php
new file mode 100644 (file)
index 0000000..96de80a
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/**
+ * A console controller for the "continued hashing miner".
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2012 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 HubConsoleMinerController extends BaseController implements Controller {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Init additional filter chains
+               foreach (array('bootstrap','shutdown') as $filterChain) {
+                       $this->initFilterChain($filterChain);
+               } // END - foreach
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a command resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        */
+       public static final function createHubConsoleMinerController (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new HubConsoleMinerController();
+
+               // Set the command resolver
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $controllerInstance;
+       }
+
+       /**
+        * Handles the given request and response
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // Add more filters by the command
+               $commandInstance->addExtraFilters($this, $requestInstance);
+
+               // Run the pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run the pre filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Flush the response out
+               $responseInstance->flushBuffer();
+       }
+
+       /**
+        * Add a bootstrap filter
+        *
+        * @param       $filterInstance         A Filterable class
+        * @return      void
+        */
+       public function addBootstrapFilter (Filterable $filterInstance) {
+               $this->addFilter('bootstrap', $filterInstance);
+       }
+
+       /**
+        * Executes all bootstrap filters
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+       }
+
+       /**
+        * Add a shutdown filter
+        *
+        * @param       $filterInstance         A Filterable class
+        * @return      void
+        */
+       public function addShutdownFilter (Filterable $filterInstance) {
+               $this->addFilter('shutdown', $filterInstance);
+       }
+
+       /**
+        * Executes all shutdown filters
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) {
+               $this->executeFilters('shutdown', $requestInstance, $responseInstance);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/factories/states/miner/.htaccess b/application/hub/main/factories/states/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/states/miner/class_MinerStateFactory.php b/application/hub/main/factories/states/miner/class_MinerStateFactory.php
new file mode 100644 (file)
index 0000000..5120f3d
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/**
+ * A factory class for miner states
+ *
+ * @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 MinerStateFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of a configurable miner state and sets it in the
+        * given miner instance.
+        *
+        * @param       $stateName              Name of the state
+        * @param       $minerInstance  A MinerHelper class instance
+        * @return      $stateInstance  A Stateable class instance
+        */
+       public static final function createMinerStateInstanceByName ($stateName, MinerHelper $minerInstance) {
+               // Then construct the class' configuraton entry
+               $className = 'miner_' . $stateName . '_state_class';
+
+               // Get a class from that configuration entry
+               $stateInstance = self::createObjectByConfiguredName($className, array($minerInstance));
+
+               // Once we have that state, set it in the miner instance
+               $minerInstance->setStateInstance($stateInstance);
+
+               // For any purposes, return the state instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/miner/.htaccess b/application/hub/main/filter/bootstrap/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrap b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrap
new file mode 100644 (file)
index 0000000..b80cc4d
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * A ??? filter for bootstrapping 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 MinerBootstrap???Filter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createMinerBootstrap???Filter () {
+               // Get a new instance
+               $filterInstance = new MinerBootstrap???Filter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Now do something
+               $this->partialStub('Please implement this step.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php
new file mode 100644 (file)
index 0000000..3998123
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * A BufferQueue filter for bootstrapping 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 MinerBootstrapBufferQueueInitializerFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createMinerBootstrapBufferQueueInitializerFilter () {
+               // Get a new instance
+               $filterInstance = new MinerBootstrapBufferQueueInitializerFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Init all buffer queues
+               $minerInstance->initBufferQueues();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php
new file mode 100644 (file)
index 0000000..7919af3
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * A ExtraBootstrapping filter for bootstrapping 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 MinerBootstrapExtraBootstrappingFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerBootstrapExtraBootstrappingFilter () {
+               // Get a new instance
+               $filterInstance = new MinerBootstrapExtraBootstrappingFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If $minerInstance is null (no NullPointerException here)
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Do some extra bootstrapping steps
+               $minerInstance->doBootstrapping();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php
new file mode 100644 (file)
index 0000000..08d0c7c
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+/**
+ * A GenericActivation filter for bootstrapping 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 MinerBootstrapGenericActivationFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createMinerBootstrapGenericActivationFilter () {
+               // Get a new instance
+               $filterInstance = new MinerBootstrapGenericActivationFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        Maybe we want to do somthing more here?
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get a miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Set the flag
+               $minerInstance->enableIsActive();
+
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The miner has been activated.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/class_BaseMinerFilter.php b/application/hub/main/filter/class_BaseMinerFilter.php
new file mode 100644 (file)
index 0000000..bfad264
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A generic filter for miner sub-project
+ *
+ * @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 BaseMinerFilter extends BaseHubFilter {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Real name of class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/miner/.htaccess b/application/hub/main/filter/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/miner/class_Miner b/application/hub/main/filter/miner/class_Miner
new file mode 100644 (file)
index 0000000..9bca1d6
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A ??? filter for miners
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Hub 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???Filter extends BaseminerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createMiner???Filter () {
+               // Get a new instance
+               $filterInstance = new Miner???Filter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Implement this!
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/miner/class_MinerInitializationFilter.php b/application/hub/main/filter/miner/class_MinerInitializationFilter.php
new file mode 100644 (file)
index 0000000..5785e5b
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * A Initialization filter 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 MinerInitializationFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerInitializationFilter () {
+               // Get a new instance
+               $filterInstance = new MinerInitializationFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        0% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // The default miner-mode is from our configuration
+               $minerMode = $this->getConfigInstance()->getConfigEntry('miner_default_mode');
+
+               // Is the miner 'mode' parameter set?
+               if ($requestInstance->isRequestElementSet('mode')) {
+                       // Then use this which overrides the config entry temporarily
+                       $minerMode = $requestInstance->getRequestElement('mode');
+               } else {
+                       // Set it for easier re-usage
+                       $requestInstance->setRequestElement('mode', $minerMode);
+               }
+
+               // Now convert the miner-mode in a class name
+               $className = 'Hub' . $this->convertToClassName($minerMode) . 'Miner';
+
+               // And try to instance it
+               try {
+                       // Get an instance
+                       $minerInstance = ObjectFactory::createObjectByName($className);
+
+                       // Get a registry
+                       $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+                       // Set the app instance
+                       $minerInstance->setApplicationInstance($applicationInstance);
+
+                       // Add miner-specific filters
+                       $minerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+               } catch (ClassNotFoundException $e) {
+                       // This exception means, the miner mode is invalid.
+                       // @TODO Can we rewrite this to app_exit() ?
+                       $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']:  miner mode ' . $minerMode . ' is invalid.');
+               }
+
+               // Set the miner instance in registry
+               Registry::getRegistry()->addInstance('miner', $minerInstance);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php b/application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php
new file mode 100644 (file)
index 0000000..8e3286d
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * A PhpRequirements filter 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 MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerPhpRequirementsFilter () {
+               // Get a new instance
+               $filterInstance = new MinerPhpRequirementsFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If a required PHP function is not available
+        * @todo        Add more test and try to add an extra message to the thrown exception
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // By default, the requirement check is passed and zero checks are failed
+               $checkPassed = TRUE;
+               $checksFailed = 0;
+
+               // Socket support is essential...
+               if (!function_exists('socket_create')) {
+                       // Test failed
+                       $checkPassed = FALSE;
+                       $checksFailed++;
+               } // END -if
+
+               // Are all tests passed?
+               if ($checkPassed === FALSE) {
+                       // Throw an exception
+                       throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
+               } // END - if
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php b/application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php
new file mode 100644 (file)
index 0000000..e671de2
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * A welcome-teaser filter for the miner
+ *
+ * @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 MinerWelcomeTeaserFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerWelcomeTeaserFilter () {
+               // Get a new instance
+               $filterInstance = new MinerWelcomeTeaserFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If $nodeInstance is null (no NullPointerException here)
+        * @todo        Handle over the $responseInstance to outputConsoleTeaser()
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get node instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Now output the teaser
+               $minerInstance->outputConsoleTeaser();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/shutdown/miner/.htaccess b/application/hub/main/filter/shutdown/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php b/application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php
new file mode 100644 (file)
index 0000000..8481f1d
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * A shutdown filter for shutting down the miner. This filter should be the
+ * last one in 'shutdown' chain so the hub is shutted down at the very end of
+ * its life... R.I.P. little miner...
+ *
+ * @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 MinerShutdownFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerShutdownFilter () {
+               // Get a new instance
+               $filterInstance = new MinerShutdownFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If $nodeInstance is null (no NullPointerException please)
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get node instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Shutdown the miner. This should be the last line
+               $minerInstance->doShutdown();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/filter/task/miner/.htaccess b/application/hub/main/filter/task/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php
new file mode 100644 (file)
index 0000000..8f132ef
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * A TaskHandlerInitializer filter 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 MinerTaskHandlerInitializerFilter extends BaseMinerFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public static final function createMinerTaskHandlerInitializerFilter () {
+               // Get a new instance
+               $filterInstance = new MinerTaskHandlerInitializerFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @throws      FilterChainException    If we need to interrupt the filter chain
+        * @todo        5% done
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get miner instance
+               //$minerInstance = Registry::getRegistry()->getInstance('miner');
+
+               // Get a new task handler instance
+               $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
+
+               // Register all tasks:
+               //
+               // 1) A task for ...
+               //$taskInstance = ObjectFactory::createObjectByConfiguredName('miner_???_task_class');
+               //$handlerInstance->registerTask('miner_???', $taskInstance);
+
+               // Put the task handler in registry
+               Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/miner/.htaccess b/application/hub/main/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/miner/chash/.htaccess b/application/hub/main/miner/chash/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/miner/chash/class_HubChashMiner.php b/application/hub/main/miner/chash/class_HubChashMiner.php
new file mode 100644 (file)
index 0000000..dbc20dd
--- /dev/null
@@ -0,0 +1,147 @@
+<?php
+/**
+ * A hub-mcrypt miner 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/>.
+ */
+class HubChashMiner extends BaseHubMiner implements MinerHelper, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set version number
+               $this->setVersion('0.0.0');
+       }
+
+       /**
+        * Creates an instance of this hub-miner class
+        *
+        * @return      $minerInstance  An instance of this hub-miner class
+        */
+       public final static function createHubChashMiner () {
+               // Get a new instance
+               $minerInstance = new HubChashMiner();
+
+               // Return the instance
+               return $minerInstance;
+       }
+
+       /**
+        * This method fills the in-buffer with (a) test unit(s) which are mainly
+        * used for development of the crunching part. They must be enabled in
+        * configuration, or else your miner runs out of WUs and waits for more
+        * to show up.
+        *
+        * In this method we already know that the in-buffer is going depleted so
+        * we don't need to double-check it here.
+        *
+        * @return      void
+        */
+       protected function fillInBufferQueueWithTestUnits () {
+               // Are test units enabled?
+               if ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'N') {
+                       // They are disabled, so skip any further steps
+                       return;
+               } elseif ($this->getStateInstance()->isMinerStateVirgin()) {
+                       // No virgin miners please, because they usually have no test units ready for crunching
+                       return;
+               }
+
+               // Get a test-unit generator instance
+               $generatorInstance = ObjectFactory::createObjectByConfiguredName('miner_test_unit_generator_class');
+
+               // We don't need an iterator here because we just need to generate some test units
+               for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('miner_max_text_unit_amount'); $idx++) {
+                       // Get a test unit from it
+                       $unitInstance = $generatorInstance->generateNextUnitInstance();
+
+                       // ... and finally queue it to the in-buffer queue
+                       $this->queueUnitInstanceToInBuffer($unitInstance);
+               } // END - for
+       }
+
+       /**
+        * This method fills the in-buffer with (real) WUs which will be crunched
+        * and the result be sent back to the key producer instance.
+        *
+        * @return      void
+        */
+       protected function fillInBufferQueueWithWorkUnits () {
+               // This miner's state must not be one of these: 'virgin'
+               if ($this->getStateInstance()->isMinerStateVirgin()) {
+                       // We can silently skip here, until the generation is finished
+                       return;
+               } // END - if
+
+               // @TODO Implement this method
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Method to "bootstrap" the miner. This step does also apply provided
+        * command-line arguments stored in the request instance. No buffer queue
+        * will be initialized here, we only do "general" things here.
+        *
+        * @return      void
+        * @todo        Implement this method
+        */
+       public function doBootstrapping () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Outputs the console teaser. This should only be executed on startup or
+        * full restarts. This method generates some space around the teaser.
+        *
+        * @return      void
+        */
+       public function outputConsoleTeaser () {
+               // Output all lines
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput('Continued Hashing Miner v' . $this->getVersion() . ' is starting ...');
+               self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Miner Developer Team');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
+               self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
+               self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+       }
+
+       /**
+        * Add some miner-specific filters
+        *
+        * @param       $controllerInstance     An object of a Controller instance
+        * @param       $responseInstance       An object of a Responseable instance
+        * @return      void
+        * @todo        0% done
+        */
+       public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) {
+               // Add some filters here
+               $this->partialStub('Please add some miner-specific filters, if required.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/miner/class_ b/application/hub/main/miner/class_
new file mode 100644 (file)
index 0000000..090621d
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A hub-miner class for the '???' mode
+ *
+ * @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 Hub???Miner extends BaseHubMiner implements MinerHelper, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set version number
+               $this->setVersion('x.x');
+       }
+
+       /**
+        * Creates an instance of this hub-miner class
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      $minerInstance          An instance of this hub-miner class
+        */
+       public final static function createHub???Miner (Requestable $requestInstance) {
+               // Get a new instance
+               $minerInstance = new Hub???Miner();
+
+               // Set the request instance
+               $minerInstance->setRequestInstance($requestInstance);
+
+               // Return the instance
+               return $minerInstance;
+       }
+
+       /**
+        * Method to "bootstrap" the miner. This step does also apply provided
+        * command-line arguments stored in the request instance. The regular miner
+        * should communicate with the bootstrap-miners at this point.
+        *
+        * @return      void
+        * @todo        Implement this method
+        */
+       public function doBootstrapping () {
+               // Call generic (parent) bootstrapping method first
+               parent::doGenericBootstrapping();
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Outputs the console teaser. This should only be executed on startup or
+        * full restarts. This method generates some space around the teaser.
+        *
+        * @return      void
+        */
+       public function outputConsoleTeaser () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Add some miner-specific filters
+        *
+        * @return      void
+        */
+       public function addExtraHubFilters () {
+               // Add some filters here
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/miner/class_BaseHubMiner.php b/application/hub/main/miner/class_BaseHubMiner.php
new file mode 100644 (file)
index 0000000..a8e3223
--- /dev/null
@@ -0,0 +1,210 @@
+<?php
+/**
+ * A general hub miner class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2012 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 BaseHubMiner extends BaseHubSystem implements Updateable {
+       /**
+        * Version information
+        */
+       private $version = 'x.x';
+
+       /**
+        * By default no miner is active
+        */
+       private $isActive = FALSE;
+
+       /**
+        * All buffer queue instances (a FIFO)
+        */
+       private $bufferInstance = NULL;
+
+       /**
+        * Stacker name for incoming queue
+        */
+       const STACKER_NAME_IN_QUEUE = 'in_queue';
+
+       /**
+        * Stacker name for outcoming queue
+        */
+       const STACKER_NAME_OUT_QUEUE = 'out_queue';
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Init this miner
+               $this->initMiner();
+       }
+
+       /**
+        * Initialize the miner generically
+        *
+        * @return      void
+        */
+       private function initMiner () {
+               // Init the state
+               MinerStateFactory::createMinerStateInstanceByName('init', $this);
+       }
+
+       /**
+        * Getter for version
+        *
+        * @return      $version        Version number of this miner
+        */
+       protected final function getVersion () {
+               return $this->version;
+       }
+
+       /**
+        * Setter for version
+        *
+        * @param       $version        Version number of this miner
+        * @return      void
+        */
+       protected final function setVersion ($version) {
+               $this->version = (string) $version;
+       }
+
+       /**
+        * Checks whether the in-buffer queue is filled by comparing it's current
+        * amount of entries against a threshold.
+        *
+        * @return      $isFilled       Whether the in-buffer is filled
+        */
+       protected function isInBufferQueueFilled () {
+               // Determine it
+               $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('miner_in_buffer_min_threshold'));
+
+               // And return the result
+               return $isFilled;
+       }
+
+       /**
+        * This method fills the in-buffer with (a) test unit(s) which are mainly
+        * used for development of the crunching part. They must be enabled in
+        * configuration, or else your miner runs out of WUs and waits for more
+        * to show up.
+        *
+        * In this method we already know that the in-buffer is going depleted so
+        * we don't need to double-check it here.
+        *
+        * @return      void
+        */
+       abstract protected function fillInBufferQueueWithTestUnits ();
+
+       /**
+        * This method fills the in-buffer with (real) WUs which will be crunched
+        * and the result be sent back to the key producer instance.
+        *
+        * @return      void
+        */
+       abstract protected function fillInBufferQueueWithWorkUnits ();
+
+       /**
+        * Enables/disables the miner (just sets a flag)
+        *
+        * @param       $version        Version number of this miner
+        * @return      void
+        */
+       public final function enableIsActive ($isActive = TRUE) {
+               $this->isActive = (bool) $isActive;
+       }
+
+       /**
+        * Determines whether the miner is active
+        *
+        * @return      $isActive       Whether the miner is active
+        */
+       public final function isActive () {
+               return $this->isActive;
+       }
+
+       /**
+        * Initializes all buffer queues (mostly in/out). This method is demanded
+        * by the MinerHelper interface.
+        *
+        * @return      void
+        */
+       public function initBufferQueues () {
+               /*
+                * Initialize both buffer queues, we can use the FIFO class here
+                * directly and encapsulate its method calls with protected methods.
+                */
+               $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('miner_buffer_stacker_class');
+
+               // Initialize common stackers, like in/out
+               $this->bufferInstance->initStacks(array(
+                       self::STACKER_NAME_IN_QUEUE,
+                       self::STACKER_NAME_OUT_QUEUE
+               ));
+
+               // Output debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('MINER: All buffers are now initialized.');
+       }
+
+       /**
+        * This method determines if the in-buffer is going to depleted and if so,
+        * it fetches more WUs from the network. If no WU can be fetched from the
+        * network and if enabled, a random test WU is being generated.
+        *
+        * This method is demanded from the MinerHelper interface.
+        *
+        * @return      void
+        */
+       public function doFetchWorkUnits () {
+               // Simply check if we have enough WUs left in the in-buffer queue (a FIFO)
+               if (!$this->isInBufferQueueFilled()) {
+                       // The in-buffer queue needs filling, so head out and get some work
+                       $this->fillInBufferQueueWithWorkUnits();
+
+                       // Is the buffer still not filled and are test-packages allowed?
+                       if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) {
+                               // Then fill the in-buffer with (one) test-unit(s)
+                               $this->fillInBufferQueueWithTestUnits();
+                       } // END - if
+               } // END - if
+       }
+
+       /**
+        * Updates a given field with new value
+        *
+        * @param       $fieldName              Field to update
+        * @param       $fieldValue             New value to store
+        * @return      void
+        * @throws      DatabaseUpdateSupportException  If this class does not support database updates
+        * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
+        */
+       public function updateDatabaseField ($fieldName, $fieldValue) {
+               // Unfinished
+               $this->partialStub('Unfinished!');
+               return;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/miner/.htaccess b/application/hub/main/states/miner/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/miner/class_ b/application/hub/main/states/miner/class_
new file mode 100644 (file)
index 0000000..b2020ce
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * A ??? miner state 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 Miner???State extends BaseMinerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('!!!');
+       }
+
+       /**
+        * 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 createMiner???State (MinerHelper $minerInstance) {
+               // Get new instance
+               $stateInstance = new Miner???State();
+
+               // 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;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        */
+       public function executeState (Executor $executorInstance) {
+               $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString());
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/miner/class_BaseMinerState.php b/application/hub/main/states/miner/class_BaseMinerState.php
new file mode 100644 (file)
index 0000000..e1a0ed3
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A general miner state 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/>.
+ */
+class BaseMinerState extends BaseState {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Validates whether the state is 'active' or throws an exception if
+        * it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active'
+        */
+       public function validateMinerStateIsActive () {
+               // Just compare it...
+               if (!$this instanceof MinerActiveState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
+
+       /**
+        * Checks if this state is 'virgin'
+        *
+        * @return      $isVirgin       Whether this state is 'virgin'
+        */
+       public function isMinerStateVirgin () {
+               // Just compare it...
+               return ($this instanceof MinerVirginState);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/miner/init/.htaccess b/application/hub/main/states/miner/init/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/miner/init/class_MinerInitState.php b/application/hub/main/states/miner/init/class_MinerInitState.php
new file mode 100644 (file)
index 0000000..02d3532
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * A Init miner state class
+ *
+ * @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 MinerInitState extends BaseMinerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('init');
+       }
+
+       /**
+        * 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) {
+               // Get new instance
+               $stateInstance = new MinerInitState();
+
+               // Set the miner instance
+               $stateInstance->setMinerInstance($minerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        */
+       public function executeState (Executor $executorInstance) {
+               // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there
+               $executorInstance->prepareUnitProduction($this);
+       }
+
+       /**
+        * An encrypted message has been generated so we change the state to
+        * 'virgin'.
+        *
+        * @return      void
+        */
+       public function encryptedMessageGenerated () {
+               // Change the state now to 'virgin'
+               MinerStateFactory::createMinerStateInstanceByName('virgin', $this->getMinerInstance());
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/miner/virgin/.htaccess b/application/hub/main/states/miner/virgin/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/miner/virgin/class_MinerVirginState.php b/application/hub/main/states/miner/virgin/class_MinerVirginState.php
new file mode 100644 (file)
index 0000000..0145061
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * A Virgin miner state 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/>.
+ */
+class MinerVirginState extends BaseMinerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('virgin');
+       }
+
+       /**
+        * 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) {
+               // Get new instance
+               $stateInstance = new MinerVirginState();
+
+               // Set the miner instance
+               $stateInstance->setMinerInstance($minerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        */
+       public function executeState (Executor $executorInstance) {
+               // Produce some keys now
+               $executorInstance->produceKeys($this);
+       }
+}
+
+// [EOF]
+?>