use in any case PeerID for peersInIP to avoid keeping references

This commit is contained in:
Giovanni Petrantoni 2021-02-27 21:31:59 +09:00
parent fae38e0146
commit 67d0926e89
3 changed files with 3 additions and 3 deletions

View File

@ -198,7 +198,7 @@ method unsubscribePeer*(g: GossipSub, peer: PeerID) =
# remove from peer IPs collection too
if pubSubPeer.sendConn != nil:
g.peersInIP.withValue(pubSubPeer.sendConn.observedAddr, s):
s[].excl(pubSubPeer)
s[].excl(pubSubPeer.peerId)
if s[].len == 0:
g.peersInIP.del(pubSubPeer.sendConn.observedAddr)

View File

@ -46,7 +46,7 @@ proc colocationFactor(g: GossipSub, peer: PubSubPeer): float64 =
let
address = peer.sendConn.observedAddr
g.peersInIP.mgetOrPut(address, initHashSet[PubSubPeer]()).incl(peer)
g.peersInIP.mgetOrPut(address, initHashSet[PeerID]()).incl(peer.peerId)
let
ipPeers = g.peersInIP[address]
len = ipPeers.len.float64

View File

@ -146,7 +146,7 @@ type
parameters*: GossipSubParams
topicParams*: Table[string, TopicParams]
directPeersLoop*: Future[void]
peersInIP*: Table[MultiAddress, HashSet[PubSubPeer]]
peersInIP*: Table[MultiAddress, HashSet[PeerID]]
heartbeatEvents*: seq[AsyncEvent]