/**
* 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
// 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));
$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.
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));
}
}