mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-15 00:04:36 +00:00
fix: take into account the ENR seq to determine if a peer is new or not (#945)
This commit is contained in:
parent
f0ed5e32d5
commit
6ab2cfb53b
@ -341,9 +341,14 @@ func (pm *PeerManager) AddDiscoveredPeer(p service.PeerData, connectNow bool) {
|
|||||||
//Check if the peer is already present, if so skip adding
|
//Check if the peer is already present, if so skip adding
|
||||||
_, err := pm.host.Peerstore().(wps.WakuPeerstore).Origin(p.AddrInfo.ID)
|
_, err := pm.host.Peerstore().(wps.WakuPeerstore).Origin(p.AddrInfo.ID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
pm.logger.Debug("peer already in peerStore", logging.HostID("peer", p.AddrInfo.ID))
|
enr, err := pm.host.Peerstore().(wps.WakuPeerstore).ENR(p.AddrInfo.ID)
|
||||||
return
|
// Verifying if the enr record is more recent (DiscV5 and peer exchange can return peers already seen)
|
||||||
|
if err == nil && enr.Record().Seq() > p.ENR.Seq() {
|
||||||
|
pm.logger.Debug("found discovered peer already in peerStore", logging.HostID("peer", p.AddrInfo.ID))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
supportedProtos := []protocol.ID{}
|
supportedProtos := []protocol.ID{}
|
||||||
if len(p.PubsubTopics) == 0 && p.ENR != nil {
|
if len(p.PubsubTopics) == 0 && p.ENR != nil {
|
||||||
// Try to fetch shard info and supported protocols from ENR to arrive at pubSub topics.
|
// Try to fetch shard info and supported protocols from ENR to arrive at pubSub topics.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user