From: Roland Häder Date: Sun, 3 Mar 2013 22:35:39 +0000 (+0000) Subject: Use array_push() instead of [] as array_push() checks if parameter 1 is really an... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=88fd171613ace75f26534529af8b2af213217d33;p=hub.git Use array_push() instead of [] as array_push() checks if parameter 1 is really an array --- diff --git a/application/hub/config.php b/application/hub/config.php index d63a50b4c..8c9e48060 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -273,6 +273,9 @@ $cfg->setConfigEntry('node_request_node_list_answer_stacker_class', 'FiLoStacker // CFG: NODE-REQUEST-NODE-LIST-ENTRY-STACKER-CLASS $cfg->setConfigEntry('node_request_node_list_entry_stacker_class', 'FiLoStacker'); +// CFG: DHT-STACKER-CLASS +$cfg->setConfigEntry('dht_stacker_class', 'FiLoStacker'); + // CFG: NODE-ANNOUNCEMENT-ANSWER-TEMPLATE-TYPE $cfg->setConfigEntry('node_announcement_answer_template_type', 'xml/answer/announcement'); @@ -402,6 +405,9 @@ $cfg->setConfigEntry('stacker_decoded_package_max_size', 100); // CFG: STACKER-DHT-BOOTSTRAP-MAX-SIZE $cfg->setConfigEntry('stacker_dht_bootstrap_max_size', 10); +// CFG: STACKER-DHT-INSERT-NODE-MAX-SIZE +$cfg->setConfigEntry('stacker_dht_insert_node_max_size', 100); + // CFG: NEWS-MAIN-LIMIT $cfg->setConfigEntry('news_main_limit', 5); diff --git a/application/hub/interfaces/distributable/class_Distributable.php b/application/hub/interfaces/distributable/class_Distributable.php index dc828071d..94d2f4ab3 100644 --- a/application/hub/interfaces/distributable/class_Distributable.php +++ b/application/hub/interfaces/distributable/class_Distributable.php @@ -90,6 +90,20 @@ interface Distributable extends FrameworkInterface { * @return void */ function updateDhtData (); + + /** + * Checks whether there are entries in "INSERT" node data stack + * + * @return $isPending Whether there are pending entries + */ + function ifInsertNodeDataPending (); + + /** + * Inserts a single entry of node data into the DHT + * + * @return void + */ + function insertSingleNodeData (); } // [EOF] diff --git a/application/hub/main/dht/class_BaseDht.php b/application/hub/main/dht/class_BaseDht.php index 597cc209a..9b94558b0 100644 --- a/application/hub/main/dht/class_BaseDht.php +++ b/application/hub/main/dht/class_BaseDht.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class BaseDht extends BaseHubSystem { + /** + * Stacker name for "INSERT" node data + */ + const STACKER_NAME_INSERT_NODE = 'dht_insert_node'; + /** * Protected constructor * @@ -32,6 +37,15 @@ class BaseDht extends BaseHubSystem { // Call parent constructor parent::__construct($className); + // Get a stacker instance for this DHT + $stackerInstance = ObjectFactory::createObjectByConfiguredName('dht_stacker_class'); + + // Set it in this class + $this->setStackerInstance($stackerInstance); + + // Init all stackers + $this->initStackers(); + /* * Get the state factory and create the initial state, we don't need * the state instance here @@ -39,6 +53,22 @@ class BaseDht extends BaseHubSystem { DhtStateFactory::createDhtStateInstanceByName('init', $this); } + /** + * Initializes all stackers + * + * @return void + */ + private function initStackers () { + // "Walk" through all (more will be added as needed + foreach ( + array( + self::STACKER_NAME_INSERT_NODE, + ) as $stackerName) { + // Init this stack + $this->getStackerInstance()->initStacker($stackerName); + } // END - foreach + } + /** * Updates/refreshes DHT data (e.g. status). * @@ -49,6 +79,31 @@ class BaseDht extends BaseHubSystem { // Set some dummy configuration entries, e.g. dht_status $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); } + + /** + * Checks whether there are entries in "INSERT" node data stack + * + * @return $isPending Whether there are pending entries + */ + public function ifInsertNodeDataPending () { + // Determine it if it is not empty + $isPending = ($this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_INSERT_NODE) === FALSE); + + // Return status + return $isPending; + } + + /** + * Inserts a single entry of node data into the DHT + * + * @return void + */ + public function insertSingleNodeData () { + // Get next node data from stack + $nodeData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_INSERT_NODE); + + die(__METHOD__ . ':nodeData=' . print_r($nodeData, TRUE)); + } } // [EOF] diff --git a/application/hub/main/dht/node/class_NodeDhtFacade.php b/application/hub/main/dht/node/class_NodeDhtFacade.php index f78bca4e2..794c38f09 100644 --- a/application/hub/main/dht/node/class_NodeDhtFacade.php +++ b/application/hub/main/dht/node/class_NodeDhtFacade.php @@ -255,7 +255,6 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable { * * @param $nodeList An array from an earlier database result instance * @return void - * @todo ~10% done */ public function insertNodeList (array $nodeList) { // If no node is in the list (array), skip the rest of this method @@ -267,8 +266,11 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable { return; } // END - if - // @TODO Not finish yet - $this->partialStub('DHT: Needs implementing to insert ' . count($nodeList) . ' entry(-ies) into DHT.'); + // Put them all into a stack + foreach ($nodeList as $nodeData) { + // Insert all entries + $this->getStackerInstance()->pushNamed(self::STACKER_NAME_INSERT_NODE, $nodeData); + } // END - foreach } } diff --git a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php index 30c65ac25..c50970d51 100644 --- a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php +++ b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php @@ -85,7 +85,7 @@ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); // Prepare next message ("hello" message to all returned nodes) - $this->prepareNextMessage($messageData, $packageInstance); + //$this->prepareNextMessage($messageData, $packageInstance); } /** diff --git a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php index 143afbd22..fe39ae849 100644 --- a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -119,7 +119,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha */ protected function initMessageConfigurationData (array $messageData) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(' REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true)); // "Walk" throught the config-copy array foreach ($this->configCopy as $targetKey => $sourceKey) { @@ -130,8 +130,17 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); } // END - foreach + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.'); + // Query local DHT for nodes except given session id - $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData($messageData, $this, XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, BaseHubNode::OBJECT_LIST_SEPARATOR); + $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData( + $messageData, + $this, + XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, + XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, + BaseHubNode::OBJECT_LIST_SEPARATOR + ); // Set it serialized in configuration (temporarily) $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(serialize($nodeList))); diff --git a/application/hub/main/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php index 0467df236..d09646d85 100644 --- a/application/hub/main/handler/tasks/class_TaskHandler.php +++ b/application/hub/main/handler/tasks/class_TaskHandler.php @@ -285,7 +285,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { $currentTask['task_instance']->accept($this->getVisitorInstance()); // Remember this task - $tasks[] = $currentTask; + array_push($tasks, $currentTask); // Advance to next one $this->getListInstance()->getIterator()->next(); diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index 558ba1f35..6651198a5 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -272,7 +272,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ public function accept (Visitor $visitorInstance) { // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START'); // Visit this listener $visitorInstance->visitListener($this); @@ -283,7 +283,7 @@ class BaseListener extends BaseHubSystem implements Visitable { } // END - if // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED'); } /** diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index bebe4e1e5..680ab86b5 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -105,7 +105,7 @@ class TcpListener extends BaseListener implements Listenable { * that all connections on this port are now our resposibility to * send/recv data, disconnect, etc.. */ - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { // Handle this socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -125,7 +125,7 @@ class TcpListener extends BaseListener implements Listenable { } // END - if // Start listen for connections - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Listening for connections.'); + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Listening for connections.'); if (!socket_listen($mainSocket)) { // Handle this socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -145,7 +145,7 @@ class TcpListener extends BaseListener implements Listenable { } // END - if // Now, we want non-blocking mode - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Setting non-blocking mode.'); + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.'); if (!socket_set_nonblock($mainSocket)) { // Handle this socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -190,7 +190,7 @@ class TcpListener extends BaseListener implements Listenable { $this->setHandlerInstance($handlerInstance); // Output message - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); } /** @@ -217,14 +217,14 @@ class TcpListener extends BaseListener implements Listenable { // Some new peers found? if ($left < 1) { // Debug message - //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); // Nothing new found return; } // END - if // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); // Do we have changed peers? if (in_array($this->getSocketResource(), $readers)) { @@ -307,7 +307,7 @@ class TcpListener extends BaseListener implements Listenable { $currentSocket = $this->getIteratorInstance()->current(); // Handle it here, if not main server socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource()); if (($currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] != BaseConnectionHelper::CONNECTION_TYPE_SERVER) && ($currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] != $this->getSocketResource())) { // ... or else it will raise warnings like 'Transport endpoint is not connected' $this->getHandlerInstance()->processRawDataFromResource($currentSocket); diff --git a/application/hub/main/listener/udp/class_UdpListener.php b/application/hub/main/listener/udp/class_UdpListener.php index b20f838c6..3c7127f48 100644 --- a/application/hub/main/listener/udp/class_UdpListener.php +++ b/application/hub/main/listener/udp/class_UdpListener.php @@ -74,7 +74,7 @@ class UdpListener extends BaseListener implements Listenable { * that all connections on this port are now our resposibility to * send/recv data, disconnect, etc.. */ - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { // Handle the socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -94,7 +94,7 @@ class UdpListener extends BaseListener implements Listenable { } // END - if // Now, we want non-blocking mode - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Setting non-blocking mode.'); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.'); if (!socket_set_nonblock($mainSocket)) { // Handle the socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -114,7 +114,7 @@ class UdpListener extends BaseListener implements Listenable { } // END - if // Set the option to reuse the port - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Setting re-use address option.'); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting re-use address option.'); if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) { // Handle the socket error with a faked recipientData array $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); @@ -143,7 +143,7 @@ class UdpListener extends BaseListener implements Listenable { $this->setHandlerInstance($handlerInstance); // Output message - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); } /** @@ -173,7 +173,7 @@ class UdpListener extends BaseListener implements Listenable { return; } elseif ($lastError > 0) { // Other error detected - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Error detected: ' . socket_strerror($lastError)); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError)); // Skip further processing return; @@ -183,7 +183,7 @@ class UdpListener extends BaseListener implements Listenable { } // END - if // Debug only - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port); + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port); } /** diff --git a/application/hub/main/lists/class_BaseList.php b/application/hub/main/lists/class_BaseList.php index c4d183768..3add91458 100644 --- a/application/hub/main/lists/class_BaseList.php +++ b/application/hub/main/lists/class_BaseList.php @@ -136,7 +136,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable { $this->listGroups[$groupName]->addEntry($subGroup, $hash); // Add the hash to the index - $this->listIndex[] = $hash; + array_push($this->listIndex, $hash); // Add the instance itself to the list $this->listEntries[$hash] = $instance; @@ -172,7 +172,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable { // Is the list entry set? if ($this->isHashValid($hash)) { // Add it - $array[] = $this->listEntries[$hash]; + array_push($array, $this->listEntries[$hash]); //* DEBUG: */ print __METHOD__.": ADDED!\n"; } // END - if } // END - foreach @@ -202,7 +202,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable { //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash); // Add the hash to the index - $this->listIndex[] = $hash; + array_push($this->listIndex, $hash); //* DEBUG: */ print $groupName.'/'.$this->count().chr(10); // Now add the entry to the list diff --git a/application/hub/main/package/fragmenter/class_PackageFragmenter.php b/application/hub/main/package/fragmenter/class_PackageFragmenter.php index 3a9adc3ed..277083d6e 100644 --- a/application/hub/main/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/main/package/fragmenter/class_PackageFragmenter.php @@ -379,7 +379,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); $this->chunks[$finalHash][] = $rawData; - $this->chunkHashes[$finalHash][] = $rawDataHash; + array_push($this->chunkHashes[$finalHash], $rawDataHash); } } diff --git a/application/hub/main/pools/peer/class_DefaultPeerPool.php b/application/hub/main/pools/peer/class_DefaultPeerPool.php index e2fce1b11..c7ee45d91 100644 --- a/application/hub/main/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/main/pools/peer/class_DefaultPeerPool.php @@ -168,7 +168,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // "Walk" through all socket arrays foreach ($socketArrays as $socketArray) { // Add the socket - $sockets[] = $socketArray[self::SOCKET_ARRAY_RESOURCE]; + array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); } // END - foreach // Return it @@ -200,7 +200,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Does it match? if ($socketArray[self::SOCKET_ARRAY_CONN_TYPE] === $connectionType) { // Add the socket - $sockets[] = $socketArray[self::SOCKET_ARRAY_RESOURCE]; + array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); } // END - if } // END - foreach diff --git a/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php b/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php index 2220c2b9b..5a436dd55 100644 --- a/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php +++ b/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php @@ -69,8 +69,11 @@ class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable { * @return void */ public function executeTask () { + // "Cache" handler instance + $handlerInstance = $this->getHandlerInstance(); + // Are there chunks to handle or a final array to assemble? - if ($this->getHandlerInstance()->ifUnassembledChunksAvailable()) { + if ($handlerInstance->ifUnassembledChunksAvailable()) { /* * Then do the final steps: * @@ -82,19 +85,19 @@ class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable { * 4) If the package is assembled back together, hash it again for * the very final verification. */ - $this->getHandlerInstance()->assembleChunksFromFinalArray(); - } elseif ($this->getHandlerInstance()->ifUnhandledChunksWithFinalAvailable()) { + $handlerInstance->assembleChunksFromFinalArray(); + } elseif ($handlerInstance->ifUnhandledChunksWithFinalAvailable()) { /* * Then handle them (not all!). This should push all chunks into a * 'final array' for last verification. */ - $this->getHandlerInstance()->handleAvailableChunksWithFinal(); - } elseif ($this->getHandlerInstance()->ifRawPackageDataIsAvailable()) { + $handlerInstance->handleAvailableChunksWithFinal(); + } elseif ($handlerInstance->ifRawPackageDataIsAvailable()) { /* * The final raw package data is back together again. So feed it * into the next stack for further decoding/processing */ - $this->getHandlerInstance()->handledAssembledRawPackageData(); + $handlerInstance->handledAssembledRawPackageData(); } } } diff --git a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php index 44f717e5e..0d3393a42 100644 --- a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php +++ b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php @@ -74,13 +74,16 @@ class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable { * @return void */ public function executeTask () { + // "Cache" decoder instance + $decoderInstance = $this->getDecoderInstance(); + // Check if the stacker has some entries left - if ($this->getDecoderInstance()->ifUnhandledRawPackageDataLeft()) { + if ($decoderInstance->ifUnhandledRawPackageDataLeft()) { // Then handle it - $this->getDecoderInstance()->handleRawPackageData(); - } elseif ($this->getDecoderInstance()->ifDeocedPackagesLeft()) { + $decoderInstance->handleRawPackageData(); + } elseif ($decoderInstance->ifDeocedPackagesLeft()) { // Some decoded packages have arrived (for this peer) - $this->getDecoderInstance()->handleDecodedPackage(); + $decoderInstance->handleDecodedPackage(); } } } diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php index ffbaec9a2..0ae14beb9 100644 --- a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php +++ b/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php @@ -71,6 +71,12 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { public function executeTask () { // "Cache" the DHT instance $dhtInstance = $this->getDhtInstance(); + + // Are there "INSERT" node data entries? + if ($dhtInstance->ifInsertNodeDataPending()) { + // Then insert a single entry + $dhtInstance->insertSingleNodeData(); + } // END - if } }