From 35871df2ede1f1dc12223601e268ef37b4cfc0f6 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 26 Mar 2014 20:10:17 +0100 Subject: [PATCH] Allow 'init' state for bootstrap nodes. Signed-off-by: Roland Haeder --- .../hub/main/helper/dht/class_DhtBootstrapHelper.php | 7 +++++-- application/hub/main/states/dht/class_BaseDhtState.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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 -- 2.39.5