From 4207beae0de12141f50185256cac6045896f8ed4 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 18 May 2020 18:38:45 +0300 Subject: [PATCH] only count an outbound connection if it has a pubsub stream --- gossipsub.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index 9de15d6..f1ce13a 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -356,10 +356,21 @@ func (gs *GossipSubRouter) AddPeer(p peer.ID, proto protocol.ID) { // track the connection direction outbound := false conns := gs.p.host.Network().ConnsToPeer(p) +loop: for _, c := range conns { if c.Stat().Direction == network.DirOutbound { - outbound = true - break + // only count the connection if it has a pubsub stream + for _, s := range c.GetStreams() { + switch s.Protocol() { + case FloodSubID: + fallthrough + case GossipSubID_v10: + fallthrough + case GossipSubID_v11: + outbound = true + break loop + } + } } } gs.outbound[p] = outbound