From: Roland Häder Date: Mon, 4 Feb 2013 19:57:09 +0000 (+0000) Subject: The DHT query task is now holding an instance of the DHT facade (to speed-up things) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8d02a735a5d3fc9c67962308a20fc9d7c18bdaf1;p=hub.git The DHT query task is now holding an instance of the DHT facade (to speed-up things) --- diff --git a/application/hub/config.php b/application/hub/config.php index d79f9f1ad..151722b01 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -725,8 +725,8 @@ $cfg->setConfigEntry('package_decoder_class', 'PackageDecoder'); // @TODO This is very static, rewrite it to more flexible $cfg->setConfigEntry('package_recipient_max_count', 3); -// CFG: NODE-DHT-CLASS -$cfg->setConfigEntry('node_dht_class', 'NodeDhtFacade'); +// CFG: DHT-CLASS +$cfg->setConfigEntry('dht_class', 'NodeDhtFacade'); /////////////////////////////////////////////////////////////////////////////// // Peer states diff --git a/application/hub/main/factories/dht/class_DhtObjectFactory.php b/application/hub/main/factories/dht/class_DhtObjectFactory.php index c4009be2c..40c29be85 100644 --- a/application/hub/main/factories/dht/class_DhtObjectFactory.php +++ b/application/hub/main/factories/dht/class_DhtObjectFactory.php @@ -35,25 +35,21 @@ class DhtObjectFactory extends ObjectFactory { /** * Returns a singleton (registry-based) DHT object instance * - * @param $nodeInstance An instance of a NodeHelper class * @return $dhtInstance An instance of a DHT object class */ - public static final function createDhtObjectInstance (NodeHelper $nodeInstance) { + public static final function createDhtObjectInstance () { // If there is no handler? - if (Registry::getRegistry()->instanceExists('node_dht')) { + if (Registry::getRegistry()->instanceExists('dht')) { // Get handler from registry - $dhtInstance = Registry::getRegistry()->getInstance('node_dht'); + $dhtInstance = Registry::getRegistry()->getInstance('dht'); } else { // Get the handler instance - $dhtInstance = self::createObjectByConfiguredName('node_dht_class'); + $dhtInstance = self::createObjectByConfiguredName('dht_class'); // Add it to the registry - Registry::getRegistry()->addInstance('node_dht', $dhtInstance); + Registry::getRegistry()->addInstance('dht', $dhtInstance); } - // Set node instance in DHT instance - $dhtInstance->setNodeInstance($nodeInstance); - // Return the instance return $dhtInstance; } diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php index 1baa4d659..f281d9eba 100644 --- a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php +++ b/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php @@ -41,6 +41,12 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { // Get new instance $taskInstance = new NodeDhtQueryTask(); + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtObjectInstance(); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + // Return the prepared instance return $taskInstance; }