// @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
/**
* 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;
}
// 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;
}