Skip to content

Commit

Permalink
fix: update peers ENRs in peer store in case they are updated (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Jun 19, 2024
1 parent 93e9ba2 commit cda18f9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions waku/node/peer_manager/peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,16 @@ proc addPeer*(pm: PeerManager, remotePeerInfo: RemotePeerInfo, origin = UnknownO
if pm.peerStore[AddressBook][remotePeerInfo.peerId] == remotePeerInfo.addrs and
pm.peerStore[KeyBook][remotePeerInfo.peerId] == remotePeerInfo.publicKey and
pm.peerStore[ENRBook][remotePeerInfo.peerId].raw.len > 0:
trace "peer already managed and ENR info is already saved",
remote_peer_id = $remotePeerInfo.peerId
return
let incomingEnr = remotePeerInfo.enr.valueOr:
trace "peer already managed and incoming ENR is empty",
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",
peerId = remotePeerInfo.peerId, addresses = remotePeerInfo.addrs
Expand Down

0 comments on commit cda18f9

Please sign in to comment.