From: Roland Haeder Date: Wed, 26 Mar 2014 19:10:17 +0000 (+0100) Subject: Allow 'init' state for bootstrap nodes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=35871df2ede1f1dc12223601e268ef37b4cfc0f6;p=hub.git Allow 'init' state for bootstrap nodes. Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/helper/dht/class_DhtBootstrapHelper.php b/application/hub/main/helper/dht/class_DhtBootstrapHelper.php index ec5b91eeb..70627b69f 100644 --- a/application/hub/main/helper/dht/class_DhtBootstrapHelper.php +++ b/application/hub/main/helper/dht/class_DhtBootstrapHelper.php @@ -82,8 +82,11 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { * @return void */ public function sendPackage (Distributable $dhtInstance) { - // Sanity check: Is the dht in the approx. state? (virgin) - $dhtInstance->getStateInstance()->validateDhtStateIsVirgin(); + /* + * Sanity check: Is the DHT in the approx. state? 'init' for bootstrap + * nodes and 'virgin' for all others. + */ + $dhtInstance->getStateInstance()->validateDhtStateIsVirginOrInit(); // Compile the template, this inserts the loaded dht data into the gaps. $this->getTemplateInstance()->compileTemplate(); diff --git a/application/hub/main/states/dht/class_BaseDhtState.php b/application/hub/main/states/dht/class_BaseDhtState.php index 88c2de0c6..78b10f3cf 100644 --- a/application/hub/main/states/dht/class_BaseDhtState.php +++ b/application/hub/main/states/dht/class_BaseDhtState.php @@ -41,9 +41,9 @@ class BaseDhtState extends BaseState { * @return void * @throws InvalidStateException If the state is not 'virgin' */ - public function validateDhtStateIsVirgin () { + public function validateDhtStateIsVirginOrInit () { // Just compare it... - if (!$this instanceof DhtVirginState) { + if ((!$this instanceof DhtVirginState) && (!$this instanceof DhtInitState)) { // Throw the exception throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE); } // END - if