]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
Used correct method
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index 3a70b2959f1af7d264f005807cc71579ff87b5c2..898f925d793f2a523ff881615c312cbf4ae86b28 100644 (file)
@@ -136,7 +136,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         */
        private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) {
                // Generate a pseudo-random string
-               $randomString = $this->generateRandomString(255);
+               $randomString = $this->getCryptoInstance()->randomString(255);
 
                // Hash and encrypt the string so we become a node id (also documented as "hub id")
                $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
@@ -286,7 +286,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                        self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . '');
                } else {
                        // Generate a pseudo-random string
-                       $randomString = $this->generateRandomString(255);
+                       $randomString = $this->getCryptoInstance()->randomString(255);
 
                        // Hash and encrypt the string so we become a node id (also documented as "hub id")
                        $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
@@ -309,10 +309,13 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                // Search for the node number one which is hard-coded the default
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
+               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR  , 1);
+               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $this->getRequestInstance()->getRequestElement('mode'));
                $searchInstance->setLimit(1);
 
+               // Remember it for later usage
+               $this->setSearchInstance($searchInstance);
+
                // Get a random string
                $randomString = $this->generateRamdomString(255);
 
@@ -344,7 +347,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                                 * "tables". This allows a smooth update for the underlaying
                                 * database table.
                                 */
-                               $this->generatePrivateKeyAndHash($searchInstance);
+                               $this->generatePrivateKeyAndHash($this->getSearchInstance());
                        } else {
                                // Get the node id from result and set it
                                $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
@@ -358,7 +361,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                         * Generate it in a private method (no confusion with 'private
                         * method access' and 'private key' here! ;-)).
                         */
-                       $this->generatePrivateKeyAndHash($searchInstance);
+                       $this->generatePrivateKeyAndHash($this->getSearchInstance());
                }
        }
 
@@ -374,8 +377,8 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                assert($requestInstance instanceof Requestable);
 
                // Add node number and type
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
+               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR  , 1);
+               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode'));
 
                // Add the node id
                $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());