Fix table assertion, edited while iterating

(the fix is not so nice.. adds plenty of allocations, but for now should
be ok)
This commit is contained in:
Giovanni Petrantoni 2020-04-05 01:19:10 +09:00
parent e39bf0a4cf
commit 3514733060
1 changed files with 6 additions and 3 deletions

View File

@ -298,10 +298,13 @@ proc rebalanceMesh(g: GossipSub, topic: string) {.async.} =
proc dropFanoutPeers(g: GossipSub) {.async.} =
# drop peers that we haven't published to in
# GossipSubFanoutTTL seconds
for topic in g.lastFanoutPubSub.keys:
if Moment.now > g.lastFanoutPubSub[topic]:
g.lastFanoutPubSub.del(topic)
var dropping = newSeq[string]()
for topic, val in g.lastFanoutPubSub:
if Moment.now > val:
dropping.add(topic)
g.fanout.del(topic)
for topic in dropping:
g.lastFanoutPubSub.del(topic)
proc getGossipPeers(g: GossipSub): Table[string, ControlMessage] {.gcsafe.} =
## gossip iHave messages to peers