From ee915cc1da5831b95fd165ba50d2a2c37d60dbf3 Mon Sep 17 00:00:00 2001 From: Evan Vigil-McClanahan <evan@helium.com> Date: Tue, 16 Aug 2022 17:51:51 -0700 Subject: [PATCH 1/2] add ability to not gossip with miners --- config/docker-val.config.src | 2 +- config/val.config.src | 2 +- src/miner_util.erl | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/docker-val.config.src b/config/docker-val.config.src index c67ee945b..0959ff345 100644 --- a/config/docker-val.config.src +++ b/config/docker-val.config.src @@ -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} ]}, diff --git a/config/val.config.src b/config/val.config.src index c45b1594b..15a8cc9b1 100644 --- a/config/val.config.src +++ b/config/val.config.src @@ -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} ] diff --git a/src/miner_util.erl b/src/miner_util.erl index 8b4195fb4..c3ff05eac 100644 --- a/src/miner_util.erl +++ b/src/miner_util.erl @@ -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, @@ -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(<<"release_info">>, libp2p_peer:signed_metadata(Peer), undefined) == undefined. + true_predicate(_Peer) -> true. From d4aba6e1c61a4ed1f4d41e1d0e5cfd7fd76fdc6f Mon Sep 17 00:00:00 2001 From: Evan Vigil-McClanahan <evan@helium.com> Date: Wed, 17 Aug 2022 10:18:01 -0700 Subject: [PATCH 2/2] use node type instead --- src/miner_util.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner_util.erl b/src/miner_util.erl index c3ff05eac..a39da9efd 100644 --- a/src/miner_util.erl +++ b/src/miner_util.erl @@ -147,7 +147,7 @@ random_miner_predicate(Peer) -> random_non_miner_predicate(Peer) -> not libp2p_peer:is_stale(Peer, timer:minutes(360)) andalso - maps:get(<<"release_info">>, libp2p_peer:signed_metadata(Peer), undefined) == undefined. + maps:get(<<"node_type">>, libp2p_peer:signed_metadata(Peer), undefined) /= <<"gateway">>. true_predicate(_Peer) -> true.