diff --git a/packages/portalnetwork/src/networks/contentLookup.ts b/packages/portalnetwork/src/networks/contentLookup.ts index 87408426d..e486295e8 100644 --- a/packages/portalnetwork/src/networks/contentLookup.ts +++ b/packages/portalnetwork/src/networks/contentLookup.ts @@ -73,6 +73,10 @@ export class ContentLookup { // Sort known peers by distance to the content const nearest = this.network.routingTable.values() for (const enr of nearest) { + // // Skip if the node has an active uTP request + if (this.network.portal.uTP.hasRequests(enr.nodeId) === true) { + continue + } const dist = distance(enr.nodeId, this.contentId) this.lookupPeers.push({ enr, distance: Number(dist) }) this.meta.set(enr.nodeId, { enr: enr.encodeTxt(), distance: bigIntToHex(dist) }) @@ -189,6 +193,10 @@ export class ContentLookup { this.logger(`received ${res.enrs.length} ENRs for closer nodes`) for (const enr of res.enrs) { const decodedEnr = ENR.decode(enr as Uint8Array) + // // Skip if the node has an active uTP request + if (this.network.portal.uTP.hasRequests(decodedEnr.nodeId) === true) { + continue + } if (!this.meta.has(decodedEnr.nodeId)) { const dist = distance(decodedEnr.nodeId, this.contentId) this.lookupPeers.push({ enr: decodedEnr, distance: Number(dist) }) diff --git a/packages/portalnetwork/src/networks/nodeLookup.ts b/packages/portalnetwork/src/networks/nodeLookup.ts index 05a2e76b9..dff02db2b 100644 --- a/packages/portalnetwork/src/networks/nodeLookup.ts +++ b/packages/portalnetwork/src/networks/nodeLookup.ts @@ -59,6 +59,8 @@ export class NodeLookup { private selectClosestPending(): ENR[] { return Array.from(this.pendingNodes.values()) + // Skip nodes with active uTP requests + .filter((peer) => this.network.portal.uTP.hasRequests(peer.nodeId) === false) .sort((a, b) => Number(distance(a.nodeId, this.nodeSought) - distance(b.nodeId, this.nodeSought)), ) @@ -91,6 +93,11 @@ export class NodeLookup { continue } + // Skip if the node has an active uTP request + if (this.network.portal.uTP.hasRequests(nodeId) === true) { + continue + } + // Add to pending this.pendingNodes.set(nodeId, decodedEnr) } catch (error) {