Skip to content

Commit 5c7cdc0

Browse files
author
Tal Muskal
committed
fixed: support for v1.5.0
1 parent 5384f4a commit 5c7cdc0

File tree

3 files changed

+57
-30
lines changed

3 files changed

+57
-30
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,21 @@ Total system ram, state_db_size, Processor type, VM or not, etc.
3535
# Installation instructions
3636

3737
## Requirements
38-
- Works on any EOSIO node that runs v1.2.0 and up.
38+
- Works on any EOSIO node that runs v1.5.0 and up. (see older tags for older versions)
3939

4040
## Building the plugin [Install on your nodeos server]
4141
1. run
4242
```
43-
cd <eosio-source-dir>/plugins
44-
git clone https://github.com/bancorprotocol/eos-producer-heartbeat-plugin.git producer_heartbeat_plugin
43+
cd <eosio-source-dir>
44+
cd plugins
45+
git clone https://github.com/LiquidEOS/eos-producer-heartbeat-plugin.git producer_heartbeat_plugin
46+
git checkout tags/v1.5.0
47+
cd ..
48+
git apply plugins/producer_heartbeat_plugin/install.patch
49+
./eosio_build.sh -s "EOS"
50+
sudo ./eosio_install.sh
4551
```
46-
2. Add the following line to `<eosio-source-dir>/plugins/CMakeLists.txt` with other `add_subdirectory` items
47-
```
48-
add_subdirectory(producer_heartbeat_plugin)
49-
```
50-
51-
3. Add the following line to the bottom of `<eosio-source-dir>/programs/nodeos/CMakeLists.txt`
52-
```
53-
target_link_libraries( nodeos PRIVATE -Wl,${whole_archive_flag} producer_heartbeat_plugin -Wl,${no_whole_archive_flag})
54-
```
55-
4. Build and install nodeos as usual. You could even just `cd <eosio-source-dir>/build` and then `sudo make install`
52+
2. Build and install nodeos as usual.
5653

5754
# Setup permissions
5855
Use a dedicated key for this action. This step is not mandatory (especially on testnets), you can use your active key instead and set ```heartbeat-permission = active```

install.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
2+
index 8c93df9c4..927e1bc5e 100644
3+
--- a/plugins/CMakeLists.txt
4+
+++ b/plugins/CMakeLists.txt
5+
@@ -20,6 +20,7 @@ add_subdirectory(mongo_db_plugin)
6+
add_subdirectory(login_plugin)
7+
add_subdirectory(test_control_plugin)
8+
add_subdirectory(test_control_api_plugin)
9+
+add_subdirectory(producer_heartbeat_plugin)
10+
11+
# Forward variables to top level so packaging picks them up
12+
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS} PARENT_SCOPE)
13+
diff --git a/programs/nodeos/CMakeLists.txt b/programs/nodeos/CMakeLists.txt
14+
index 6bddeacb8..8c9fafda5 100644
15+
--- a/programs/nodeos/CMakeLists.txt
16+
+++ b/programs/nodeos/CMakeLists.txt
17+
@@ -73,6 +73,8 @@ endif()
18+
19+
include(additionalPlugins)
20+
21+
+target_link_libraries( ${NODE_EXECUTABLE_NAME} PRIVATE -Wl,${whole_archive_flag} producer_heartbeat_plugin -Wl,${no_whole_archive_flag})
22+
+
23+
copy_bin( ${NODE_EXECUTABLE_NAME} )
24+
install( TARGETS
25+
${NODE_EXECUTABLE_NAME}

producer_heartbeat_plugin.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
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>
@@ -19,7 +17,14 @@
1917

2018
namespace 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)
403408
void 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

Comments
 (0)