fix: update peers ENRs in peer store in case they are updated (#2818)

This commit is contained in:
gabrielmer 2024-06-19 17:29:55 +02:00 committed by GitHub
parent 93e9ba22aa
commit cda18f96ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -128,9 +128,16 @@ proc addPeer*(pm: PeerManager, remotePeerInfo: RemotePeerInfo, origin = UnknownO
if pm.peerStore[AddressBook][remotePeerInfo.peerId] == remotePeerInfo.addrs and if pm.peerStore[AddressBook][remotePeerInfo.peerId] == remotePeerInfo.addrs and
pm.peerStore[KeyBook][remotePeerInfo.peerId] == remotePeerInfo.publicKey and pm.peerStore[KeyBook][remotePeerInfo.peerId] == remotePeerInfo.publicKey and
pm.peerStore[ENRBook][remotePeerInfo.peerId].raw.len > 0: pm.peerStore[ENRBook][remotePeerInfo.peerId].raw.len > 0:
trace "peer already managed and ENR info is already saved", let incomingEnr = remotePeerInfo.enr.valueOr:
remote_peer_id = $remotePeerInfo.peerId trace "peer already managed and incoming ENR is empty",
return remote_peer_id = $remotePeerInfo.peerId
return
if pm.peerStore[ENRBook][remotePeerInfo.peerId].raw == incomingEnr.raw or
pm.peerStore[ENRBook][remotePeerInfo.peerId].seqNum > incomingEnr.seqNum:
trace "peer already managed and ENR info is already saved",
remote_peer_id = $remotePeerInfo.peerId
return
trace "Adding peer to manager", trace "Adding peer to manager",
peerId = remotePeerInfo.peerId, addresses = remotePeerInfo.addrs peerId = remotePeerInfo.peerId, addresses = remotePeerInfo.addrs