mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-07 15:23:08 +00:00
only count an outbound connection if it has a pubsub stream
This commit is contained in:
parent
09e6d9e1e3
commit
4207beae0d
13
gossipsub.go
13
gossipsub.go
@ -356,10 +356,21 @@ func (gs *GossipSubRouter) AddPeer(p peer.ID, proto protocol.ID) {
|
|||||||
// track the connection direction
|
// track the connection direction
|
||||||
outbound := false
|
outbound := false
|
||||||
conns := gs.p.host.Network().ConnsToPeer(p)
|
conns := gs.p.host.Network().ConnsToPeer(p)
|
||||||
|
loop:
|
||||||
for _, c := range conns {
|
for _, c := range conns {
|
||||||
if c.Stat().Direction == network.DirOutbound {
|
if c.Stat().Direction == network.DirOutbound {
|
||||||
|
// 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
|
outbound = true
|
||||||
break
|
break loop
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gs.outbound[p] = outbound
|
gs.outbound[p] = outbound
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user