From 69208b08398b7d4719fdd396ea5b945b94ba79a9 Mon Sep 17 00:00:00 2001 From: Gabriel mermelstein Date: Tue, 18 Jun 2024 13:55:34 +0200 Subject: [PATCH] update peers ENRs in peer store in case it's updated --- waku/node/peer_manager/peer_manager.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index a2993c5241..637e005bd8 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -128,9 +128,14 @@ 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 + if remotePeerInfo.enr.isNone(): + trace "peer already managed and incoming ENR is empty" + return + + if remotePeerInfo.enr.get().raw == pm.peerStore[ENRBook][remotePeerInfo.peerId].raw: + 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