@libp2p/interface 1.0.2-742915567 → 1.0.2-83dfc7dc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/content-routing/index.d.ts +12 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-discovery/index.d.ts +7 -0
- package/dist/src/peer-discovery/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.d.ts +10 -3
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/content-routing/index.ts +13 -5
- package/src/index.ts +23 -0
- package/src/peer-discovery/index.ts +8 -0
- package/src/peer-routing/index.ts +11 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoutingOptions } from '../index.js';
|
|
2
2
|
import type { PeerInfo } from '../peer-info/index.js';
|
|
3
3
|
import type { CID } from 'multiformats/cid';
|
|
4
4
|
/**
|
|
@@ -21,6 +21,13 @@ import type { CID } from 'multiformats/cid';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare const contentRoutingSymbol: unique symbol;
|
|
24
|
+
/**
|
|
25
|
+
* Implementers of this interface can provide a ContentRouting implementation to
|
|
26
|
+
* interested callers.
|
|
27
|
+
*/
|
|
28
|
+
export interface ContentRoutingProvider {
|
|
29
|
+
[contentRoutingSymbol]: ContentRouting;
|
|
30
|
+
}
|
|
24
31
|
export interface ContentRouting {
|
|
25
32
|
/**
|
|
26
33
|
* The implementation of this method should ensure that network peers know the
|
|
@@ -33,7 +40,7 @@ export interface ContentRouting {
|
|
|
33
40
|
* await contentRouting.provide(cid)
|
|
34
41
|
* ```
|
|
35
42
|
*/
|
|
36
|
-
provide(cid: CID, options?:
|
|
43
|
+
provide(cid: CID, options?: RoutingOptions): Promise<void>;
|
|
37
44
|
/**
|
|
38
45
|
* Find the providers of the passed CID.
|
|
39
46
|
*
|
|
@@ -46,7 +53,7 @@ export interface ContentRouting {
|
|
|
46
53
|
* }
|
|
47
54
|
* ```
|
|
48
55
|
*/
|
|
49
|
-
findProviders(cid: CID, options?:
|
|
56
|
+
findProviders(cid: CID, options?: RoutingOptions): AsyncIterable<PeerInfo>;
|
|
50
57
|
/**
|
|
51
58
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
52
59
|
* retrieved by another network peer using the get method.
|
|
@@ -61,7 +68,7 @@ export interface ContentRouting {
|
|
|
61
68
|
* await contentRouting.put(key, value)
|
|
62
69
|
* ```
|
|
63
70
|
*/
|
|
64
|
-
put(key: Uint8Array, value: Uint8Array, options?:
|
|
71
|
+
put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions): Promise<void>;
|
|
65
72
|
/**
|
|
66
73
|
* Retrieves a value from the network corresponding to the passed key.
|
|
67
74
|
*
|
|
@@ -74,6 +81,6 @@ export interface ContentRouting {
|
|
|
74
81
|
* const value = await contentRouting.get(key)
|
|
75
82
|
* ```
|
|
76
83
|
*/
|
|
77
|
-
get(key: Uint8Array, options?:
|
|
84
|
+
get(key: Uint8Array, options?: RoutingOptions): Promise<Uint8Array>;
|
|
78
85
|
}
|
|
79
86
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,eAAwC,CAAA;AAEzE;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAA;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE1D;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAE1E;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhF;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACpE"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type { StreamHandler, StreamHandlerOptions } from './stream-handler/index
|
|
|
26
26
|
import type { Topology } from './topology/index.js';
|
|
27
27
|
import type { Listener } from './transport/index.js';
|
|
28
28
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
29
|
+
import type { ProgressOptions } from 'progress-events';
|
|
29
30
|
/**
|
|
30
31
|
* Used by the connection manager to sort addresses into order before dialling
|
|
31
32
|
*/
|
|
@@ -609,6 +610,26 @@ export interface LoggerOptions {
|
|
|
609
610
|
export type RecursivePartial<T> = {
|
|
610
611
|
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]>;
|
|
611
612
|
};
|
|
613
|
+
/**
|
|
614
|
+
* When a routing operation involves reading values, these options allow
|
|
615
|
+
* controlling where the values are read from. By default libp2p will check
|
|
616
|
+
* local caches but may not use the network if a valid local value is found,
|
|
617
|
+
* these options allow tuning that behaviour.
|
|
618
|
+
*/
|
|
619
|
+
export interface RoutingOptions extends AbortOptions, ProgressOptions {
|
|
620
|
+
/**
|
|
621
|
+
* Pass `false` to not use the network
|
|
622
|
+
*
|
|
623
|
+
* @default true
|
|
624
|
+
*/
|
|
625
|
+
useNetwork?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* Pass `false` to not use cached values
|
|
628
|
+
*
|
|
629
|
+
* @default true
|
|
630
|
+
*/
|
|
631
|
+
useCache?: boolean;
|
|
632
|
+
}
|
|
612
633
|
export * from './connection/index.js';
|
|
613
634
|
export * from './connection-encrypter/index.js';
|
|
614
635
|
export * from './connection-gater/index.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAA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AC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0qBH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
@@ -20,6 +20,13 @@ import type { PeerInfo } from '../peer-info/index.js';
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare const peerDiscoverySymbol: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* Implementers of this interface can provide a PeerDiscovery implementation to
|
|
25
|
+
* interested callers.
|
|
26
|
+
*/
|
|
27
|
+
export interface PeerDiscoveryProvider {
|
|
28
|
+
[peerDiscoverySymbol]: PeerDiscovery;
|
|
29
|
+
}
|
|
23
30
|
export interface PeerDiscoveryEvents {
|
|
24
31
|
'peer': CustomEvent<PeerInfo>;
|
|
25
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,eAAuC,CAAA;AAEvE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;CAAG"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,eAAuC,CAAA;AAEvE;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAA;CACrC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;CAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoutingOptions } from '../index.js';
|
|
2
2
|
import type { PeerId } from '../peer-id/index.js';
|
|
3
3
|
import type { PeerInfo } from '../peer-info/index.js';
|
|
4
4
|
/**
|
|
@@ -21,6 +21,13 @@ import type { PeerInfo } from '../peer-info/index.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare const peerRoutingSymbol: unique symbol;
|
|
24
|
+
/**
|
|
25
|
+
* Implementers of this interface can provide a PeerRouting implementation to
|
|
26
|
+
* interested callers.
|
|
27
|
+
*/
|
|
28
|
+
export interface PeerRoutingProvider {
|
|
29
|
+
[peerRoutingSymbol]: PeerRouting;
|
|
30
|
+
}
|
|
24
31
|
export interface PeerRouting {
|
|
25
32
|
/**
|
|
26
33
|
* Searches the network for peer info corresponding to the passed peer id.
|
|
@@ -32,7 +39,7 @@ export interface PeerRouting {
|
|
|
32
39
|
* const peer = await peerRouting.findPeer(peerId, options)
|
|
33
40
|
* ```
|
|
34
41
|
*/
|
|
35
|
-
findPeer(peerId: PeerId, options?:
|
|
42
|
+
findPeer(peerId: PeerId, options?: RoutingOptions): Promise<PeerInfo>;
|
|
36
43
|
/**
|
|
37
44
|
* Search the network for peers that are closer to the passed key. Peer
|
|
38
45
|
* info should be yielded in ever-increasing closeness to the key.
|
|
@@ -46,6 +53,6 @@ export interface PeerRouting {
|
|
|
46
53
|
* }
|
|
47
54
|
* ```
|
|
48
55
|
*/
|
|
49
|
-
getClosestPeers(key: Uint8Array, options?:
|
|
56
|
+
getClosestPeers(key: Uint8Array, options?: RoutingOptions): AsyncIterable<PeerInfo>;
|
|
50
57
|
}
|
|
51
58
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,eAAqC,CAAA;AAEnE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAAA;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAErE;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;CACpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "1.0.2-
|
|
3
|
+
"version": "1.0.2-83dfc7dc8",
|
|
4
4
|
"description": "The interface implemented by a libp2p node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"it-pushable": "^3.2.1",
|
|
68
68
|
"it-stream-types": "^2.0.1",
|
|
69
69
|
"multiformats": "^12.1.3",
|
|
70
|
+
"progress-events": "^1.0.0",
|
|
70
71
|
"uint8arraylist": "^2.4.3"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoutingOptions } from '../index.js'
|
|
2
2
|
import type { PeerInfo } from '../peer-info/index.js'
|
|
3
3
|
import type { CID } from 'multiformats/cid'
|
|
4
4
|
|
|
@@ -23,6 +23,14 @@ import type { CID } from 'multiformats/cid'
|
|
|
23
23
|
*/
|
|
24
24
|
export const contentRoutingSymbol = Symbol.for('@libp2p/content-routing')
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Implementers of this interface can provide a ContentRouting implementation to
|
|
28
|
+
* interested callers.
|
|
29
|
+
*/
|
|
30
|
+
export interface ContentRoutingProvider {
|
|
31
|
+
[contentRoutingSymbol]: ContentRouting
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
export interface ContentRouting {
|
|
27
35
|
/**
|
|
28
36
|
* The implementation of this method should ensure that network peers know the
|
|
@@ -35,7 +43,7 @@ export interface ContentRouting {
|
|
|
35
43
|
* await contentRouting.provide(cid)
|
|
36
44
|
* ```
|
|
37
45
|
*/
|
|
38
|
-
provide(cid: CID, options?:
|
|
46
|
+
provide(cid: CID, options?: RoutingOptions): Promise<void>
|
|
39
47
|
|
|
40
48
|
/**
|
|
41
49
|
* Find the providers of the passed CID.
|
|
@@ -49,7 +57,7 @@ export interface ContentRouting {
|
|
|
49
57
|
* }
|
|
50
58
|
* ```
|
|
51
59
|
*/
|
|
52
|
-
findProviders(cid: CID, options?:
|
|
60
|
+
findProviders(cid: CID, options?: RoutingOptions): AsyncIterable<PeerInfo>
|
|
53
61
|
|
|
54
62
|
/**
|
|
55
63
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
@@ -65,7 +73,7 @@ export interface ContentRouting {
|
|
|
65
73
|
* await contentRouting.put(key, value)
|
|
66
74
|
* ```
|
|
67
75
|
*/
|
|
68
|
-
put(key: Uint8Array, value: Uint8Array, options?:
|
|
76
|
+
put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions): Promise<void>
|
|
69
77
|
|
|
70
78
|
/**
|
|
71
79
|
* Retrieves a value from the network corresponding to the passed key.
|
|
@@ -79,5 +87,5 @@ export interface ContentRouting {
|
|
|
79
87
|
* const value = await contentRouting.get(key)
|
|
80
88
|
* ```
|
|
81
89
|
*/
|
|
82
|
-
get(key: Uint8Array, options?:
|
|
90
|
+
get(key: Uint8Array, options?: RoutingOptions): Promise<Uint8Array>
|
|
83
91
|
}
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import type { StreamHandler, StreamHandlerOptions } from './stream-handler/index
|
|
|
27
27
|
import type { Topology } from './topology/index.js'
|
|
28
28
|
import type { Listener } from './transport/index.js'
|
|
29
29
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
30
|
+
import type { ProgressOptions } from 'progress-events'
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Used by the connection manager to sort addresses into order before dialling
|
|
@@ -671,6 +672,28 @@ export type RecursivePartial<T> = {
|
|
|
671
672
|
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]>
|
|
672
673
|
}
|
|
673
674
|
|
|
675
|
+
/**
|
|
676
|
+
* When a routing operation involves reading values, these options allow
|
|
677
|
+
* controlling where the values are read from. By default libp2p will check
|
|
678
|
+
* local caches but may not use the network if a valid local value is found,
|
|
679
|
+
* these options allow tuning that behaviour.
|
|
680
|
+
*/
|
|
681
|
+
export interface RoutingOptions extends AbortOptions, ProgressOptions {
|
|
682
|
+
/**
|
|
683
|
+
* Pass `false` to not use the network
|
|
684
|
+
*
|
|
685
|
+
* @default true
|
|
686
|
+
*/
|
|
687
|
+
useNetwork?: boolean
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Pass `false` to not use cached values
|
|
691
|
+
*
|
|
692
|
+
* @default true
|
|
693
|
+
*/
|
|
694
|
+
useCache?: boolean
|
|
695
|
+
}
|
|
696
|
+
|
|
674
697
|
export * from './connection/index.js'
|
|
675
698
|
export * from './connection-encrypter/index.js'
|
|
676
699
|
export * from './connection-gater/index.js'
|
|
@@ -22,6 +22,14 @@ import type { PeerInfo } from '../peer-info/index.js'
|
|
|
22
22
|
*/
|
|
23
23
|
export const peerDiscoverySymbol = Symbol.for('@libp2p/peer-discovery')
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Implementers of this interface can provide a PeerDiscovery implementation to
|
|
27
|
+
* interested callers.
|
|
28
|
+
*/
|
|
29
|
+
export interface PeerDiscoveryProvider {
|
|
30
|
+
[peerDiscoverySymbol]: PeerDiscovery
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
export interface PeerDiscoveryEvents {
|
|
26
34
|
'peer': CustomEvent<PeerInfo>
|
|
27
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoutingOptions } from '../index.js'
|
|
2
2
|
import type { PeerId } from '../peer-id/index.js'
|
|
3
3
|
import type { PeerInfo } from '../peer-info/index.js'
|
|
4
4
|
|
|
@@ -23,6 +23,14 @@ import type { PeerInfo } from '../peer-info/index.js'
|
|
|
23
23
|
*/
|
|
24
24
|
export const peerRoutingSymbol = Symbol.for('@libp2p/peer-routing')
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Implementers of this interface can provide a PeerRouting implementation to
|
|
28
|
+
* interested callers.
|
|
29
|
+
*/
|
|
30
|
+
export interface PeerRoutingProvider {
|
|
31
|
+
[peerRoutingSymbol]: PeerRouting
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
export interface PeerRouting {
|
|
27
35
|
/**
|
|
28
36
|
* Searches the network for peer info corresponding to the passed peer id.
|
|
@@ -34,7 +42,7 @@ export interface PeerRouting {
|
|
|
34
42
|
* const peer = await peerRouting.findPeer(peerId, options)
|
|
35
43
|
* ```
|
|
36
44
|
*/
|
|
37
|
-
findPeer(peerId: PeerId, options?:
|
|
45
|
+
findPeer(peerId: PeerId, options?: RoutingOptions): Promise<PeerInfo>
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
48
|
* Search the network for peers that are closer to the passed key. Peer
|
|
@@ -49,5 +57,5 @@ export interface PeerRouting {
|
|
|
49
57
|
* }
|
|
50
58
|
* ```
|
|
51
59
|
*/
|
|
52
|
-
getClosestPeers(key: Uint8Array, options?:
|
|
60
|
+
getClosestPeers(key: Uint8Array, options?: RoutingOptions): AsyncIterable<PeerInfo>
|
|
53
61
|
}
|