mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 22:43:09 +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[10].peerId] = Connected
|
||||||
pm.peerStore[ConnectionBook][peers[12].peerId] = Connected
|
pm.peerStore[ConnectionBook][peers[12].peerId] = Connected
|
||||||
|
|
||||||
# Prune the peerstore
|
# Prune the peerstore (current=15, target=5)
|
||||||
pm.prunePeerStore()
|
pm.prunePeerStore()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|||||||
@ -405,7 +405,9 @@ proc prunePeerStore*(pm: PeerManager) =
|
|||||||
|
|
||||||
# prune peers with too many failed attempts
|
# prune peers with too many failed attempts
|
||||||
var pruned = 0
|
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:
|
if peersToPrune - pruned == 0:
|
||||||
break
|
break
|
||||||
if pm.peerStore[NumberFailedConnBook][peerId] >= pm.maxFailedAttempts:
|
if pm.peerStore[NumberFailedConnBook][peerId] >= pm.maxFailedAttempts:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user