// CFG: MINER-INIT-STATE-CLASS
$cfg->setConfigEntry('miner_init_state_class', 'MinerInitState');
+// CFG: MINER-BOOTING-STATE-CLASS
+$cfg->setConfigEntry('miner_booting_state_class', 'MinerBootingState');
+
// CFG: MINER-BLOCK-FETCHER-TASK-CLASS
$cfg->setConfigEntry('miner_block_fetcher_task_class', 'MinerBlockFetcherTask');
// CFG: MINER-NODE-COMMUNICATOR-CLASS
$cfg->setConfigEntry('miner_node_communicator_class', 'MinerNodeCommunicator');
+// CFG: MINER-TEST-HASH-BLOCK-CLASS
+$cfg->setConfigEntry('miner_test_hash_block_class', 'HashBlock');
+
///////////////////////////////////////////////////////////////////////////////
// Cruncher configuration
///////////////////////////////////////////////////////////////////////////////
// CFG: CRAWLER-URL-FOUND-RSS-STACK-CLASS
$cfg->setConfigEntry('crawler_url_found_rss_stack_class', 'FiFoFileStack');
-// CFG: TEST-BLOCK-MINER-STACK-CLASS
-$cfg->setConfigEntry('test_block_miner_stack_class', 'FiFoFileStack');
-
// CFG: CRAWLER-URL-LOCAL-START-FILE-STACK-INDEX-CLASS
$cfg->setConfigEntry('crawler_url_local_start_file_stack_index_class', 'FileStackIndex');
// CFG: CRAWLER-URL-FOUND-RSS-FILE-STACK-INDEX-CLASS
$cfg->setConfigEntry('crawler_url_found_rss_file_stack_index_class', 'FileStackIndex');
-// CFG: TEST-BLOCK-MINER-FILE-STACK-INDEX-CLASS
-$cfg->setConfigEntry('test_block_miner_file_stack_index_class', 'FileStackIndex');
-
// CFG: TASK-CRAWLER-NODE-COMMUNICATOR-STARTUP-DELAY
$cfg->setConfigEntry('task_crawler_node_communicator_startup_delay', 500);
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for minable (blocks)
+ *
+ * @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 Minable extends FrameworkInterface {
+}
+
+// [EOF]
+?>
* @return void
*/
function initBufferQueues ();
+
+ /**
+ * Changes the state to 'booting' and shall be called after the block
+ * producer has been initialized.
+ *
+ * @return void
+ */
+ function blockProducerHasInitialized ();
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? block class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 ???Block extends BaseBlock implements === {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $blockInstance An instance of a === class
+ */
+ public final static function create???Block () {
+ // Get new instance
+ $blockInstance = new ???Block();
+
+ // Return the prepared instance
+ return $blockInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general Block class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 BaseBlock extends BaseHubSystem {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Hash block class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 HashBlock extends BaseBlock implements Minable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $blockInstance An instance of a Minable class
+ */
+ public final static function createHashBlock () {
+ // Get new instance
+ $blockInstance = new HashBlock();
+
+ // Return the prepared instance
+ return $blockInstance;
+ }
+}
+
+// [EOF]
+?>
* Creates an instance of a configurable crawler state and sets it in the
* given crawler instance.
*
- * @param $stateName Name of the state
+ * @param $stateName Name of the state
* @param $crawlerInstance A Crawler class instance
- * @return $stateInstance A Stateable class instance
+ * @return $stateInstance A Stateable class instance
*/
public static final function createCrawlerStateInstanceByName ($stateName, Crawler $crawlerInstance) {
// Then construct the class' configuraton entry
* Creates an instance of a configurable cruncher state and sets it in the
* given cruncher instance.
*
- * @param $stateName Name of the state
+ * @param $stateName Name of the state
* @param $cruncherInstance A CruncherHelper class instance
- * @return $stateInstance A Stateable class instance
+ * @return $stateInstance A Stateable class instance
*/
public static final function createCruncherStateInstanceByName ($stateName, CruncherHelper $cruncherInstance) {
// Then construct the class' configuraton entry
// Get a class from that configuration entry
$stateInstance = self::createObjectByConfiguredName($className, array($cruncherInstance));
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Cruncher state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
// Once we have that state, set it in the cruncher instance
$cruncherInstance->setStateInstance($stateInstance);
// Get a class from that configuration entry
$stateInstance = self::createObjectByConfiguredName($className, array($minerInstance));
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Miner state has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
// Once we have that state, set it in the miner instance
$minerInstance->setStateInstance($stateInstance);
$this->partialStub('Unfinished!');
return;
}
+
+ /**
+ * Changes the state to 'booting' and shall be called after the block
+ * producer has been initialized.
+ *
+ * @return void
+ */
+ public function blockProducerHasInitialized () {
+ // Make sure the state is correct ('init')
+ $this->getStateInstance()->validateMinerStateIsInit();
+
+ // Change it to 'booting'
+ MinerStateFactory::createMinerStateInstanceByName('booting', $this);
+ }
}
// [EOF]
// Get new instance
$producerInstance = new MinerTestGenesisBlockProducer();
- // Init the queue for this test block producer
- $stackInstance = FileStackFactory::createFileStackInstance('test', 'block_miner');
+ // Get a (minable) hash block instance
+ $minableInstance = ObjectFactory::createObjectByConfiguredName('miner_test_hash_block_class');
// Set it here
- $producerInstance->setStackInstance($stackInstance);
+ $producerInstance->setMinableInstance($minableInstance);
// Return the prepared instance
return $producerInstance;
*/
protected function initProducer () {
$this->partialStub('Please implement this method.');
+
+ // As last step, change the state of the miner, get the miner first
+ $minerInstance = Registry::getRegistry()->getInstance('miner');
+
+ // Change state to next state
+ $minerInstance->blockProducerHasInitialized();
}
/**
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Booting 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 MinerBootingState extends BaseMinerState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('booting');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $minerInstance An instance of a MinerHelper class
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createMinerBootingState (MinerHelper $minerInstance) {
+ // Get new instance
+ $stateInstance = new MinerBootingState();
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Set the miner instance
+ $stateInstance->setMinerInstance($minerInstance);
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+
+ /**
+ * 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->prepareBlockProduction($this);
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-<?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]
-?>
} // END - if
}
+ /**
+ * Validates whether the state is 'init' or throws an exception if
+ * it is every other state.
+ *
+ * @return void
+ * @throws InvalidStateException If the state is not 'init'
+ */
+ public function validateMinerStateIsInit () {
+ // Just compare it...
+ if (!$this instanceof MinerInitState) {
+ // Throw the exception
+ throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
+
/**
* Checks if this state is 'virgin'
*
--- /dev/null
+<?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]
+?>
*
* @param $executorInstance An instance of a Executor class
* @return void
+ * @todo 0% done?
*/
public function executeState (Executor $executorInstance) {
- // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there
- $executorInstance->prepareBlockProduction($this);
}
/**
-Subproject commit d5cbb96707ecc0630c05da880205f2c7f26e623b
+Subproject commit 1efa4dc3d8bd367e85e5cecf13778d06e0418415