区块链中文技术社区

EOSIO Block Producer Heartbeat

目前想检测侧链个节点的健康状况,此文将测试插件
插件源代码地址:https://github.com/LiquidEOS/eos-producer-heartbeat-plugin
前端项目地址:https://github.com/LiquidEOS/eos-producer-heartbeat

检测的原理就是,提前准备个账号,部署好收集节点信息的合约
合约地址:https://github.com/LiquidEOS/eos-producer-heartbeat/blob/master/eosio_docker/contracts/heartbeat/heartbeat.cpp

各个节点定时(heartbeat-period)将数据push到这个合约(heartbeat-contract)。

源代码编译插件

cd <eosio-source-dir>
cd plugins
git clone https://github.com/LiquidEOS/eos-producer-heartbeat-plugin.git producer_heartbeat_plugin
cd producer_heartbeat_plugin
git checkout tags/v1.5.01
cd ../..
git apply plugins/producer_heartbeat_plugin/install.patch
./eosio_build.sh -s "EOS"
sudo ./eosio_install.sh

新创建账户,并设置权限

如果是测试,这一步非必要的。

创建key

$ cleos create key --to-console
Private key: 5JPxA1FPp2fMJj2hh1ax8cuJMQchffCi3GnBcobwL5SJhyxMS9n
Public key: EOS6pZfrTRMesCnSaE1XwYSFFUtsdGeH6Ljj6xGWxFk4N5Z3T13KT

下文中 PRODUCERACCT 为出块节点账户

创建账户

cleos system newaccount PRODUCERACCT eosheartbeat EOS6pZfrTRMesCnSaE1XwYSFFUtsdGeH6Ljj6xGWxFk4N5Z3T13KT EOS6pZfrTRMesCnSaE1XwYSFFUtsdGeH6Ljj6xGWxFk4N5Z3T13KT  --stake-net '50.00 EOS' --stake-cpu '50.00 EOS'  --buy-ram-kbytes 10000

创建一个自定义的heartbeat权限

cleos set account permission PRODUCERACCT heartbeat '{"threshold":1,"keys":[{"key":"EOS6pZfrTRMesCnSaE1XwYSFFUtsdGeH6Ljj6xGWxFk4N5Z3T13KT","weight":1}]}' "active" -p PRODUCERACCT@active

将PRODUCERACCT的heartbeat权限,付给eosheartbeat,用于执行heartbeat

cleos set action permission PRODUCERACCT eosheartbeat heartbeat heartbeat

黑名单合约权限,同上

cleos set action permission PRODUCERACCT theblacklist sethash heartbeat

config添加插件支持

plugin = eosio::producer_heartbeat_plugin
heartbeat-period = 1500
heartbeat-signature-provider = HEARTBEAT_PUB_KEY=KEY:HEARTBEAT_PRIVATE_KEY
heartbeat-contract = eosheartbeat
heartbeat-permission = heartbeat
heartbeat-oncall = telegram:johndoe

稍后测试后,在做补充

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »