- 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>
*/
public function processMessage (array $messageData, Receivable $packageInstance) {
// Process generic
*/
public function processMessage (array $messageData, Receivable $packageInstance) {
// Process generic
- $this->genericProcessMessage('self_connect', $messageData, $packageInstance);
+ $this->genericProcessMessage(BaseTag::TAG_SELF_CONNECT, $messageData, $packageInstance);
$this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF);
// Set package tags
$this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF);
// Set package tags
- $this->setPackageTags(array('self_connect'));
+ $this->setPackageTags(array(BaseTags::TAG_SELF_CONNECT));
/**
* Constants for message data array
*/
/**
* 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
/**
* 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]));
// 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));
// 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?
$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.
/*
* Then don't feed this message to the miner as this causes an
* endless loop of mining.
+ // 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));
}
}
$this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE));
}
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseTags extends BaseHubSystem implements Registerable {
* 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
*/
/**
* An array with all tags
*/
$templateInstance = new XmlSelfConnectTemplateEngine();
// Init template instance
$templateInstance = new XmlSelfConnectTemplateEngine();
// Init template instance
- $templateInstance->initXmlTemplateEngine('node', 'self_connect');
+ $templateInstance->initXmlTemplateEngine('node', BaseTag::TAG_SELF_CONNECT);
// Return the prepared instance
return $templateInstance;
// Return the prepared instance
return $templateInstance;
type as much as you want here, as all will be removed by the compaction
step.
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
Array
(
[node_mode] => regular