Skip to content

Commit 952aadd

Browse files
committed
fix(dns-discovery/peer-exchange): check if peer is already tagged
If we `continue` when the peer is already known by the `peerStore` then the next step of checking the tags is useless (no tags if peer is not known). There are two ways around it: 1. either do nothing if peer is already in peer store 2. OR, do nothing if peer is in peer store and is already tagged I opted for the second approach to ensure all peers are tagged properly.
1 parent b7bc09d commit 952aadd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/dns-discovery/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ export class PeerDiscoveryDns
9696
if (!this._started) return;
9797
const peerInfos = multiaddrsToPeerInfo(peer.getFullMultiaddrs());
9898
peerInfos.forEach(async (peerInfo) => {
99+
if (
100+
(await this._components.peerStore.getTags(peerInfo.id)).find(
101+
({ name }) => name === DEFAULT_BOOTSTRAP_TAG_NAME
102+
)
103+
)
104+
return;
105+
99106
await this._components.peerStore.tagPeer(
100107
peerInfo.id,
101108
DEFAULT_BOOTSTRAP_TAG_NAME,

packages/peer-exchange/src/waku_peer_exchange_discovery.ts

-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ export class PeerExchangeDiscovery
170170

171171
if (!peerId || !multiaddrs || multiaddrs.length === 0) continue;
172172

173-
if (await this.components.peerStore.has(peerId)) continue;
174-
175173
if (
176174
(await this.components.peerStore.getTags(peerId)).find(
177175
({ name }) => name === DEFAULT_PEER_EXCHANGE_TAG_NAME

0 commit comments

Comments
 (0)