From 6935bf6f51aa678fbb64249eb82383bb66f53ef9 Mon Sep 17 00:00:00 2001 From: montecarlomind <45424199+montecarlomind@users.noreply.github.com> Date: Wed, 12 Dec 2018 20:00:17 +0800 Subject: [PATCH] Fix/#3 notify plugin (#10) * Add debug info * comment log * rm log for notify_plugin --- plugins/notify_plugin/README.md | 22 +++++++++++----------- plugins/notify_plugin/notify_plugin.cpp | 11 ++++++++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/notify_plugin/README.md b/plugins/notify_plugin/README.md index 35080a4962d..b962c6e0ead 100644 --- a/plugins/notify_plugin/README.md +++ b/plugins/notify_plugin/README.md @@ -11,7 +11,7 @@ Add some configs to your `config.ini` just as follows: plugin = eosio::notify_plugin # notify-filter-on = account:action notify-filter-on = b1: -notify-filter-on = noprom:transfer +notify-filter-on = b1:transfer notify-filter-on = eosio:delegatebw # http endpoint for each action seen on the chain. notify-receive-url = http://127.0.0.1:8080/notify @@ -32,38 +32,38 @@ And you can receive the actions on chain by watching your server endpoint: `http "account": "eosio.token", "name": "transfer", "seq_num": 1, - "receiver": "noprom", + "receiver": "b1", "block_time": "2018-09-29T11:51:06.000", "block_num": 127225, "authorization": [{ - "actor": "noprom", + "actor": "b1", "permission": "active" } ], "action_data": { - "from": "noprom", - "to": "noprom1", + "from": "b1", + "to": "b11", "quantity": "0.0001 EOS", - "memo": "Transfer from noprom to xiaoming" + "memo": "Transfer from b1 to b11" } },{ "tx_id": "b31885bada6c2d5e71b1302e87d4006c59ff2a40a12108559d76142548d8cf79", "account": "eosio.token", "name": "transfer", "seq_num": 2, - "receiver": "noprom1", + "receiver": "b11", "block_time": "2018-09-29T11:51:06.000", "block_num": 127225, "authorization": [{ - "actor": "noprom", + "actor": "b1", "permission": "active" } ], "action_data": { - "from": "noprom", - "to": "noprom1", + "from": "b1", + "to": "b11", "quantity": "0.0001 EOS", - "memo": "Transfer from noprom to xiaoming" + "memo": "Transfer from b1 to b11" } } ] diff --git a/plugins/notify_plugin/notify_plugin.cpp b/plugins/notify_plugin/notify_plugin.cpp index 65e728e9bbe..377daf8e5ef 100644 --- a/plugins/notify_plugin/notify_plugin.cpp +++ b/plugins/notify_plugin/notify_plugin.cpp @@ -134,6 +134,7 @@ fc::variant notify_plugin_impl::deserialize_action_data(action act) void notify_plugin_impl::build_message(message &msg, const block_state_ptr &block, const transaction_id_type &tx_id, const bool irreversible) { + // dlog("irreversible: ${a}", ("a", fc::json::to_pretty_string(irreversible))); auto range = irreversible ? irreversible_action_queue.equal_range(tx_id) : action_queue.equal_range(tx_id); msg.irreversible = irreversible; @@ -163,6 +164,7 @@ action_seq_type notify_plugin_impl::on_action_trace(const action_trace &act, con const auto pair = std::make_pair(tx_id, sequenced_action(act.act, act_s, act.receipt.receiver)); action_queue.insert(pair); irreversible_action_queue.insert(pair); + // dlog("on_action_trace: ${a}", ("a", fc::json::to_pretty_string(act.act))); } act_s++; @@ -195,6 +197,7 @@ void notify_plugin_impl::on_accepted_block(const block_state_ptr &block_state) { message msg; transaction_id_type tx_id; + // dlog("block_state->block->transactions: ${a}", ("a", fc::json::to_pretty_string(block_state->block->transactions))); for (const auto &trx : block_state->block->transactions) { if (trx.trx.contains()) @@ -206,11 +209,14 @@ void notify_plugin_impl::on_accepted_block(const block_state_ptr &block_state) tx_id = trx.trx.get().id(); } + // dlog("tx_id: ${a}", ("a", fc::json::to_pretty_string(tx_id))); + // dlog("action_queue.size(): ${a}", ("a", fc::json::to_pretty_string(action_queue.size()))); if (action_queue.count(tx_id)) { build_message(msg, block_state, tx_id, false); } } + // dlog("msg: ${a}", ("a", msg)); if (msg.actions.size() > 0) { send_message(msg); @@ -226,6 +232,7 @@ void notify_plugin_impl::on_irreversible_block(const block_state_ptr &block_stat { message msg; transaction_id_type tx_id; + // dlog("block_state->block->transactions: ${a}", ("a", fc::json::to_pretty_string(block_state->block->transactions))); for (const auto &trx : block_state->block->transactions) { if (trx.trx.contains()) @@ -236,12 +243,14 @@ void notify_plugin_impl::on_irreversible_block(const block_state_ptr &block_stat { tx_id = trx.trx.get().id(); } - + // dlog("tx_id: ${a}", ("a", fc::json::to_pretty_string(tx_id))); + // dlog("irreversible_action_queue.size(): ${a}", ("a", fc::json::to_pretty_string(irreversible_action_queue.size()))); if (irreversible_action_queue.count(tx_id)) { build_message(msg, block_state, tx_id, true); } } + // dlog("msg: ${a}", ("a", msg)); if (msg.actions.size() > 0) { send_message(msg);