99#include < fc/io/json.hpp>
1010#include < eosio/chain/abi_serializer.hpp>
1111
12- #include < eosio/utilities/common.hpp>
13-
1412#include < algorithm>
1513#include < cctype>
1614#include < locale>
1917
2018namespace eosio {
2119 using namespace eosio ::chain;
22-
20+ template <typename I>
21+ std::string itoh (I n, size_t hlen = sizeof (I)<<1) {
22+ static const char * digits = " 0123456789abcdef" ;
23+ std::string r (hlen, ' 0' );
24+ for (size_t i = 0 , j = (hlen - 1 ) * 4 ; i < hlen; ++i, j -= 4 )
25+ r[i] = digits[(n>>j) & 0x0f ];
26+ return r;
27+ }
2328 static appbase::abstract_plugin& _template_plugin = app().register_plugin<producer_heartbeat_plugin>();
2429
2530// https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
@@ -97,16 +102,16 @@ class producer_heartbeat_plugin_impl {
97102 }
98103 }
99104 mutable_variant_object collect_metadata (controller& cc){
100- // boost::mutex::scoped_lock lock(mtx);
101- // // get latencies table & clear table
102- // auto latencies_to_use = latencies;
103- // latencies = mutable_variant_object();
104- // latencies_sum_count.clear();
105- // lock.unlock();
105+ boost::mutex::scoped_lock lock (mtx);
106+ // get latencies table & clear table
107+ auto latencies_to_use = latencies;
108+ latencies = mutable_variant_object ();
109+ latencies_sum_count.clear ();
110+ lock.unlock ();
106111
107112 return mutable_variant_object ()
108- (" hb_version" , " 1.1.02 " )
109- (" version" , eosio::utilities::common:: itoh (static_cast <uint32_t >(app ().version ())))
113+ (" hb_version" , " 1.5.01 " )
114+ (" version" , itoh (static_cast <uint32_t >(app ().version ())))
110115 (" version_string" , app ().version_string ())
111116 (" abl_hash" , actor_blacklist_hash)
112117 (" abl_cnt" , actor_blacklist_count)
@@ -116,7 +121,7 @@ class producer_heartbeat_plugin_impl {
116121 (" vtype" , virtualization_type)
117122 (" memory" , total_memory)
118123 (" db_size" , state_db_size)
119- // ("latencies", latencies_to_use)
124+ (" latencies" , latencies_to_use)
120125 (" head" , cc.fork_db_head_block_num ());
121126 }
122127 void send_heartbeat_transaction (int retry = 0 ){
@@ -403,11 +408,11 @@ void producer_heartbeat_plugin::plugin_initialize(const variables_map& options)
403408void producer_heartbeat_plugin::plugin_startup () {
404409 ilog (" producer heartbeat plugin: plugin_startup() begin" );
405410 try {
406- // auto& chain = app().find_plugin<chain_plugin>()->chain();
407- // my->accepted_block_conn.emplace(chain.accepted_block.connect(
408- // [&](const block_state_ptr& b_state) {
409- // my->on_accepted_block(b_state);
410- // }));
411+ auto & chain = app ().find_plugin <chain_plugin>()->chain ();
412+ my->accepted_block_conn .emplace (chain.accepted_block .connect (
413+ [&](const block_state_ptr& b_state) {
414+ my->on_accepted_block (b_state);
415+ }));
411416 my->send_heartbeat_transaction ();
412417 }
413418 FC_LOG_AND_DROP ();
0 commit comments