Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Confirm there are GRPC subscribers before generating PoC keys in heartbeat #1835

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/miner_val_heartbeat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

-ifdef(TEST).
-define(BYPASS_IP_CHECK,true).
-define(BYPASS_GRPC_CHECK,true).
-else.
-define(BYPASS_IP_CHECK,false).
-define(BYPASS_GRPC_CHECK,false).
-endif.


Expand Down Expand Up @@ -105,7 +107,15 @@ handle_info({blockchain_event, {add_block, Hash, Sync, _Ledger}},
%% key proposals for this heartbeat
%% hashes of the public keys are included in the HB
%% public and private keys are cached locally
{EmpKeys, EmpKeyHashes} = generate_poc_keys(Ledger),
%% but only do this if there are gRPC clients which indicates
%% that this validator is configured to receive poc receipts
{EmpKeys, EmpKeyHashes} = case ?BYPASS_GRPC_CHECK orelse length(sibyl_bus:get_members(<<"activity_check_notification">>)) > 0 of
true ->
generate_poc_keys(Ledger);
_ ->
lager:info("No GRPC , excluding PoC ephemeral keys from heartbeat; open grpc port"),
{[],[]}
end,
lager:debug("HB poc ephemeral keys ~p", [EmpKeys]),
ok = miner_poc_mgr:save_local_poc_keys(Height, EmpKeys),
%% include any inactive GWs which have since come active
Expand Down