fix: only set disconnect time on left event (#2831)

This commit is contained in:
gabrielmer 2024-06-24 10:20:09 +02:00 committed by GitHub
parent 733edae435
commit 01050138c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -442,7 +442,9 @@ proc onPeerEvent(pm: PeerManager, peerId: PeerId, event: PeerEvent) {.async.} =
if not pm.storage.isNil: if not pm.storage.isNil:
var remotePeerInfo = pm.peerStore.get(peerId) var remotePeerInfo = pm.peerStore.get(peerId)
remotePeerInfo.disconnectTime = getTime().toUnix
if event.kind == PeerEventKind.Left:
remotePeerInfo.disconnectTime = getTime().toUnix
pm.storage.insertOrReplace(remotePeerInfo) pm.storage.insertOrReplace(remotePeerInfo)