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

add ability to not gossip with miners #1804

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion config/docker-val.config.src
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]},
{libp2p,
[
{random_peer_pred, fun miner_util:true_predicate/1},
{random_peer_pred, fun miner_util:random_non_miner_predicate/1},
{nat_map, #{ {"${NAT_INTERNAL_IP}", "${NAT_INTERNAL_PORT}"} => {"${NAT_EXTERNAL_IP}", "${NAT_EXTERNAL_PORT}"}}},
{max_tcp_connections, 2048}
]},
Expand Down
2 changes: 1 addition & 1 deletion config/val.config.src
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]},
{libp2p,
[
{random_peer_pred, fun miner_util:true_predicate/1},
{random_peer_pred, fun miner_util:random_non_miner_predicate/1},
{nat_map, #{ {"${NAT_INTERNAL_IP}", "${NAT_INTERNAL_PORT}"} => {"${NAT_EXTERNAL_IP}", "${NAT_EXTERNAL_PORT}"}}},
{max_tcp_connections, 2048}
]
Expand Down
5 changes: 5 additions & 0 deletions src/miner_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
metadata_fun/0,
random_val_predicate/1,
random_miner_predicate/1,
random_non_miner_predicate/1,
true_predicate/1,
has_valid_local_capability/2,
hbbft_perf/0,
Expand Down Expand Up @@ -144,6 +145,10 @@ random_miner_predicate(Peer) ->
not libp2p_peer:is_stale(Peer, timer:minutes(360)) andalso
maps:get(<<"release_info">>, libp2p_peer:signed_metadata(Peer), undefined) /= undefined.

random_non_miner_predicate(Peer) ->
not libp2p_peer:is_stale(Peer, timer:minutes(360)) andalso
maps:get(<<"node_type">>, libp2p_peer:signed_metadata(Peer), undefined) /= <<"gateway">>.

true_predicate(_Peer) ->
true.

Expand Down