mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
fix(networking): fix flaky peerstore test (#1554)
This commit is contained in:
parent
2f4415de02
commit
2ca2b3fc8a
@ -529,7 +529,7 @@ procSuite "Peer Manager":
|
||||
pm.peerStore[ConnectionBook][peers[10].peerId] = Connected
|
||||
pm.peerStore[ConnectionBook][peers[12].peerId] = Connected
|
||||
|
||||
# Prune the peerstore
|
||||
# Prune the peerstore (current=15, target=5)
|
||||
pm.prunePeerStore()
|
||||
|
||||
check:
|
||||
|
||||
@ -405,7 +405,9 @@ proc prunePeerStore*(pm: PeerManager) =
|
||||
|
||||
# prune peers with too many failed attempts
|
||||
var pruned = 0
|
||||
for peerId in pm.peerStore[NumberFailedConnBook].book.keys:
|
||||
# copy to avoid modifying the book while iterating
|
||||
let peerKeys = toSeq(pm.peerStore[NumberFailedConnBook].book.keys)
|
||||
for peerId in peerKeys:
|
||||
if peersToPrune - pruned == 0:
|
||||
break
|
||||
if pm.peerStore[NumberFailedConnBook][peerId] >= pm.maxFailedAttempts:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user