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

Commit d05e0d8

Browse files
committed
Confirm there are GRPC subscribers before including PoC keys in heartbeat
1 parent cc3bb64 commit d05e0d8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/miner_val_heartbeat.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626

2727
-ifdef(TEST).
2828
-define(BYPASS_IP_CHECK,true).
29+
-define(BYPASS_GRPC_CHECK,true).
2930
-else.
3031
-define(BYPASS_IP_CHECK,false).
32+
-define(BYPASS_GRPC_CHECK,false).
3133
-endif.
3234

3335

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

0 commit comments

Comments
 (0)