]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/dht/node/class_NodeDhtFacade.php
Continued:
[hub.git] / application / hub / main / dht / node / class_NodeDhtFacade.php
index e37b76cf6510463e8d9bd5463a7f7bbe39ed6bc5..98ff98bed5ed0d71a302f7fc6699d22ebd509e88 100644 (file)
@@ -58,23 +58,23 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
         *
         * @param       $dhtData        A valid array with DHT-related data (e.g. node/peer data)
         * @return      void
-        * @todo        Does the data need to be enriched?
+        * @todo        Does this data need to be enriched with more meta data?
         */
        protected function insertDataIntoDht (array $dhtData) {
                // Check if there is already an entry for given node_id
-               if ($this->getWrapperInstance()->isNodeRegisteredByNodeId($dhtData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID])) {
+               if ($this->getWrapperInstance()->isNodeRegistered($dhtData)) {
                        /*
                         * Update existing record. Please note that this step is not secure
                         * (e.g. DHT poisoning) it would be good to implement some checks if
                         * the both node owner trust each other (see sub-project 'DSHT').
                         */
-                       $this->getWrapperInstance()->updateNodeEntry($dhtData);
+                       $this->getWrapperInstance()->updateNode($dhtData);
                } else {
                        /*
                         * Inserts given node data into the DHT. As above, this step does
                         * currently not perform any security checks.
                         */
-                       $this->getWrapperInstance()->registerNodeByData($dhtData);
+                       $this->getWrapperInstance()->registerNode($dhtData);
                }
        }
 
@@ -138,7 +138,7 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
                $resultInstance = $this->getWrapperInstance()->findNodeLocalBySessionId($sessionId);
 
                // Is the next entry valid?
-               if ($resultInstance->next()) {
+               if (($resultInstance->valid()) && ($resultInstance->next())) {
                        /*
                         * Then load the first entry (more entries are being ignored and
                         * should not happen).
@@ -193,7 +193,7 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
                $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
 
                // Is there already an entry?
-               if ($resultInstance->next()) {
+               if ($resultInstance->valid()) {
                        // Entry found, so update it
                        $this->getWrapperInstance()->updateNodeByMessageData($messageData, $handlerInstance, $searchInstance);
                } elseif ($forceUpdate === FALSE) {