]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 22:42:33 +0000 (00:42 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 22:42:33 +0000 (00:42 +0200)
- got rid of some array fields as the miner doesn't need this.
- Introduced TAG_SELF_CONNECT and TAG_CLAIM_MINING_REWARD constants

Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php
application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php
application/hub/classes/package/class_NetworkPackage.php
application/hub/classes/tags/class_BaseTags.php
application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php
application/hub/templates/xml/dht_publish/publish.xml

index bd75e45058683ea9d61b719e21a86444b4d83b7c..97331fd7b1963467db79417588aa6ff4e809c3cc 100644 (file)
@@ -81,7 +81,7 @@ class PackageSelfConnectTagFilter extends BaseNodeFilter implements FilterablePa
         */
        public function processMessage (array $messageData, Receivable $packageInstance) {
                // Process generic
-               $this->genericProcessMessage('self_connect', $messageData, $packageInstance);
+               $this->genericProcessMessage(BaseTag::TAG_SELF_CONNECT, $messageData, $packageInstance);
        }
 
        /**
index 5c57946f0b98880b907d6ef5c6c2aba265de2b86..45fa460bad8478c4b0451347613bc48d69f4ab68 100644 (file)
@@ -36,7 +36,7 @@ class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode {
                $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF);
 
                // Set package tags
-               $this->setPackageTags(array('self_connect'));
+               $this->setPackageTags(array(BaseTags::TAG_SELF_CONNECT));
        }
 
        /**
index af1de4a2a5319b5d33b080685f8b509014039550..620e147281695a5e14b192657ddfef5c0e89ee51 100644 (file)
@@ -117,11 +117,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
        /**
         * Constants for message data array
         */
-       const MESSAGE_ARRAY_DATA   = 'message_data';
-       const MESSAGE_ARRAY_TYPE   = 'message_type';
-       const MESSAGE_ARRAY_SENDER = 'message_sender';
-       const MESSAGE_ARRAY_HASH   = 'message_hash';
-       const MESSAGE_ARRAY_TAGS   = 'message_tags';
+       const MESSAGE_ARRAY_DATA         = 'message_data';
+       const MESSAGE_ARRAY_TYPE         = 'message_type';
+       const MESSAGE_ARRAY_SENDER       = 'message_sender';
+       const MESSAGE_ARRAY_HASH         = 'message_hash';
+       const MESSAGE_ARRAY_TAGS         = 'message_tags';
+       const MESSAGE_ARRAY_DATA_NODE_ID = 'node-id';
 
        /**
         * Generic answer status field
@@ -1468,7 +1469,14 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                // Make sure the required elements are there
                assert(isset($messageData[self::MESSAGE_ARRAY_SENDER]));
                assert(isset($messageData[self::MESSAGE_ARRAY_HASH]));
-               assert(isset($messageData[self::MESSAGE_ARRAY_TAGS]));
+               assert(isset($messageData[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_DATA_NODE_ID]));
+
+               // Copy node id
+               $messageData[self::MESSAGE_ARRAY_DATA_NODE_ID] = $messageData[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_DATA_NODE_ID];
+
+               // Let's get rid of some fields that is not needed by the miner:
+               unset($messageData[self::MESSAGE_ARRAY_TYPE]);
+               unset($messageData[self::MESSAGE_ARRAY_DATA]);
 
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
@@ -1477,7 +1485,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]);
 
                // Is 'claim_reward' the message type?
-               if (in_array('claim_reward', $messageData[self::MESSAGE_ARRAY_TAGS])) {
+               if (in_array(BaseTag::TAG_CLAIM_MINING_REWARD, $messageData[self::MESSAGE_ARRAY_TAGS])) {
                        /*
                         * Then don't feed this message to the miner as this causes an
                         * endless loop of mining.
@@ -1485,6 +1493,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        return;
                } // END - if
 
+               // Also remove tags as the miner don't need this.
+               unset($messageData[self::MESSAGE_ARRAY_TAGS]);
+
                $this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE));
        }
 }
index f48581776d885e08b6b9d5aa0f2b0a09745b8678..da61999b32c67245a547dcd02c94c850ec2eb1cc 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseTags extends BaseHubSystem implements Registerable {
+       /**
+        * Constants for tags
+        */
+       const TAG_SELF_CONNECT        = 'self_connect';
+       const TAG_CLAIM_MINING_REWARD = 'claim_reward';
+
        /**
         * An array with all tags
         */
index 543fc7251a8beb6d20e58d849671ab849c11d9fb..d0552c20dfc6497c7eba4841a2689c4209a5d8d3 100644 (file)
@@ -62,7 +62,7 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp
                $templateInstance = new XmlSelfConnectTemplateEngine();
 
                // Init template instance
-               $templateInstance->initXmlTemplateEngine('node', 'self_connect');
+               $templateInstance->initXmlTemplateEngine('node', BaseTag::TAG_SELF_CONNECT);
 
                // Return the prepared instance
                return $templateInstance;
index 63738a82ff7ffac5006930a004c0f7e2b152e572..9608075f28ee64d526e31a9db2a7cf2c926c329b 100644 (file)
@@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
        type as much as you want here, as all will be removed by the compaction
        step.
 
-       The following example data will be published (execept __idx):
+       The following example data will be published (except __idx):
 Array
 (
     [node_mode] => regular