diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index a2993c5241..a38ad41df2 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -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