From a2c4cc05ede81bd202e27b85149cdbc41f5059da Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 Oct 2018 13:44:27 +0800 Subject: [PATCH 1/2] check for topic When accept_trx_topic or applied_trx_topic is NULL, nodeos will exit by kafka plugin. --- kafka_plugin.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kafka_plugin.cpp b/kafka_plugin.cpp index 5237e38..406f488 100755 --- a/kafka_plugin.cpp +++ b/kafka_plugin.cpp @@ -464,9 +464,12 @@ using kafka_producer_ptr = std::shared_ptr; if (options.count("applied_trx_topic") != 0) { applied_trx_topic = (char *) (options.at("applied_trx_topic").as().c_str()); } - elog("brokers_str:${j}", ("j", brokers_str)); - elog("accept_trx_topic:${j}", ("j", accept_trx_topic)); - elog("applied_trx_topic:${j}", ("j", applied_trx_topic)); + if (brokers_str != NULL) + elog("brokers_str:${j}", ("j", brokers_str)); + if (accept_trx_topic != NULL) + elog("accept_trx_topic:${j}", ("j", accept_trx_topic)); + if (applied_trx_topic != NULL) + elog("applied_trx_topic:${j}", ("j", applied_trx_topic)); if (0!=my->producer->trx_kafka_init(brokers_str,accept_trx_topic,applied_trx_topic)){ elog("trx_kafka_init fail"); @@ -538,5 +541,3 @@ using kafka_producer_ptr = std::shared_ptr; } } // namespace eosio - - From a11498047e2bdffe04a48f1cd1cb753a57bf6b0a Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 Oct 2018 14:03:24 +0800 Subject: [PATCH 2/2] parse transaction for vpn --- kafka_plugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kafka_plugin.cpp b/kafka_plugin.cpp index 406f488..fc11392 100755 --- a/kafka_plugin.cpp +++ b/kafka_plugin.cpp @@ -375,6 +375,13 @@ using kafka_producer_ptr = std::shared_ptr; const auto& trx = t->trx; string trx_json = fc::json::to_string( trx ); + if (trx.actions[0].name == "transfer") { + const auto transfer_sys = trx.actions[0].data_as(); + if(transfer_sys.to == "eosio") { + string temp = fc::json::to_string(transfer_sys); + producer->trx_kafka_sendmsg(KAFKA_TRX_ACCEPT, (char*)temp.c_str()); + } + } producer->trx_kafka_sendmsg(KAFKA_TRX_ACCEPT,(char*)trx_json.c_str()); }