Skip to content

Commit d0610c9

Browse files
committed
chore: do not dedupe at the routing level as different impls return different metadata
1 parent 0c28d66 commit d0610c9

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

packages/interface/src/blocks.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,29 @@ export interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any,
8888
/**
8989
* The minimum number of providers for the root CID that are required for
9090
* successful session creation.
91+
*
92+
* The session will become usable once this many providers have been
93+
* discovered, up to `maxProviders` providers will continue to be added.
94+
*
95+
* @default 1
96+
*/
97+
minProviders?: number
98+
99+
/**
100+
* The maximum number of providers for the root CID to be added to a session.
101+
*
102+
* @default 5
103+
*/
104+
maxProviders?: number
105+
106+
/**
107+
* When searching for providers of the root CID, implementations can check
108+
* that providers are still online and have the requested block. This setting
109+
* controls how many peers to query at the same time.
110+
*
111+
* @default 5
91112
*/
92-
providers?: number
113+
queryConcurrency?: number
93114

94115
/**
95116
* How long each queried provider has to respond either that they have the

packages/utils/src/routing.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { CodeError, start, stop } from '@libp2p/interface'
2-
import { PeerSet } from '@libp2p/peer-collections'
32
import merge from 'it-merge'
43
import type { Routing as RoutingInterface, Provider, RoutingOptions } from '@helia/interface'
54
import type { AbortOptions, ComponentLogger, Logger, PeerId, PeerInfo, Startable } from '@libp2p/interface'
@@ -38,8 +37,6 @@ export class Routing implements RoutingInterface, Startable {
3837
throw new CodeError('No content routers available', 'ERR_NO_ROUTERS_AVAILABLE')
3938
}
4039

41-
const seen = new PeerSet()
42-
4340
for await (const peer of merge(
4441
...supports(this.routers, 'findProviders')
4542
.map(router => router.findProviders(key, options))
@@ -50,13 +47,6 @@ export class Routing implements RoutingInterface, Startable {
5047
continue
5148
}
5249

53-
// deduplicate peers
54-
if (seen.has(peer.id)) {
55-
continue
56-
}
57-
58-
seen.add(peer.id)
59-
6050
yield peer
6151
}
6252
}
@@ -142,8 +132,6 @@ export class Routing implements RoutingInterface, Startable {
142132
throw new CodeError('No peer routers available', 'ERR_NO_ROUTERS_AVAILABLE')
143133
}
144134

145-
const seen = new PeerSet()
146-
147135
for await (const peer of merge(
148136
...supports(this.routers, 'getClosestPeers')
149137
.map(router => router.getClosestPeers(key, options))
@@ -152,13 +140,6 @@ export class Routing implements RoutingInterface, Startable {
152140
continue
153141
}
154142

155-
// deduplicate peers
156-
if (seen.has(peer.id)) {
157-
continue
158-
}
159-
160-
seen.add(peer.id)
161-
162143
yield peer
163144
}
164145
}

0 commit comments

Comments
 (0)