]> git.mxchange.org Git - hub.git/commitdiff
The DHT query task is now holding an instance of the DHT facade (to speed-up things)
authorRoland Häder <roland@mxchange.org>
Mon, 4 Feb 2013 19:57:09 +0000 (19:57 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 4 Feb 2013 19:57:09 +0000 (19:57 +0000)
application/hub/config.php
application/hub/main/factories/dht/class_DhtObjectFactory.php
application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php

index d79f9f1ad4c94af1f48ca4f5bf52e3d72397ae1d..151722b01105cc505256c52f6de7a1118adaf6d8 100644 (file)
@@ -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
index c4009be2c6171a4988fd9f53ae994cc136db65d9..40c29be8553ad429f8900dd8f93a124741f21f93 100644 (file)
@@ -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;
        }
index 1baa4d65907bcfc12d9928742126c6a868cc1c2c..f281d9eba1706b368e5658a78d511b22bc10072d 100644 (file)
@@ -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;
        }