@libp2p/kad-dht 16.2.7 → 16.3.0-29797a5bb
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/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/content-fetching/index.d.ts +4 -4
- package/dist/src/content-fetching/index.js +8 -8
- package/dist/src/content-fetching/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +6 -6
- package/dist/src/content-routing/index.js +4 -4
- package/dist/src/index.d.ts +10 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/kad-dht.d.ts +3 -3
- package/dist/src/kad-dht.d.ts.map +1 -1
- package/dist/src/kad-dht.js +2 -2
- package/dist/src/kad-dht.js.map +1 -1
- package/dist/src/peer-routing/index.d.ts +4 -4
- package/dist/src/peer-routing/index.js +6 -6
- package/dist/src/query/events.d.ts +1 -1
- package/dist/src/query/manager.d.ts +2 -2
- package/dist/src/query/manager.js +2 -2
- package/dist/src/query/query-path.d.ts +2 -2
- package/dist/src/query/query-path.js +1 -1
- package/dist/src/query/types.d.ts +1 -1
- package/dist/src/record/selectors.d.ts +2 -2
- package/dist/src/record/selectors.d.ts.map +1 -1
- package/dist/src/record/selectors.js +2 -2
- package/dist/src/record/selectors.js.map +1 -1
- package/dist/src/record/validators.d.ts +1 -1
- package/dist/src/routing-table/closest-peers.js +3 -3
- package/dist/src/routing-table/index.d.ts +1 -1
- package/dist/src/routing-table/index.js +1 -1
- package/dist/src/routing-table/k-bucket.js +2 -2
- package/dist/src/routing-table/refresh.d.ts +1 -1
- package/dist/src/routing-table/refresh.js +1 -1
- package/dist/src/rpc/handlers/add-provider.d.ts +3 -3
- package/dist/src/rpc/handlers/find-node.d.ts +4 -4
- package/dist/src/rpc/handlers/find-node.js +1 -1
- package/dist/src/rpc/handlers/get-providers.d.ts +5 -5
- package/dist/src/rpc/handlers/get-providers.js +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts +3 -3
- package/dist/src/rpc/handlers/get-value.js +3 -3
- package/dist/src/rpc/handlers/ping.d.ts +2 -2
- package/dist/src/rpc/handlers/put-value.d.ts +3 -3
- package/dist/src/rpc/handlers/put-value.js +2 -2
- package/dist/src/rpc/index.d.ts +5 -5
- package/dist/src/rpc/index.js +1 -1
- package/package.json +13 -13
- package/src/content-fetching/index.ts +14 -14
- package/src/content-routing/index.ts +12 -12
- package/src/index.ts +16 -2
- package/src/kad-dht.ts +2 -2
- package/src/peer-routing/index.ts +12 -12
- package/src/query/events.ts +1 -1
- package/src/query/manager.ts +4 -4
- package/src/query/query-path.ts +3 -3
- package/src/query/types.ts +1 -1
- package/src/record/selectors.ts +3 -3
- package/src/record/validators.ts +1 -1
- package/src/routing-table/closest-peers.ts +3 -3
- package/src/routing-table/index.ts +2 -2
- package/src/routing-table/k-bucket.ts +2 -2
- package/src/routing-table/refresh.ts +2 -2
- package/src/rpc/handlers/add-provider.ts +3 -3
- package/src/rpc/handlers/find-node.ts +5 -5
- package/src/rpc/handlers/get-providers.ts +6 -6
- package/src/rpc/handlers/get-value.ts +6 -6
- package/src/rpc/handlers/ping.ts +2 -2
- package/src/rpc/handlers/put-value.ts +5 -5
- package/src/rpc/index.ts +5 -5
- package/dist/typedoc-urls.json +0 -65
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Libp2pRecord } from '@libp2p/record';
|
|
2
|
-
import type { Message } from '../../message/dht.
|
|
3
|
-
import type { PeerRouting } from '../../peer-routing/index.
|
|
4
|
-
import type { DHTMessageHandler } from '../index.
|
|
2
|
+
import type { Message } from '../../message/dht.ts';
|
|
3
|
+
import type { PeerRouting } from '../../peer-routing/index.ts';
|
|
4
|
+
import type { DHTMessageHandler } from '../index.ts';
|
|
5
5
|
import type { ComponentLogger, PeerId, PeerStore } from '@libp2p/interface';
|
|
6
6
|
import type { Datastore } from 'interface-datastore';
|
|
7
7
|
export interface GetValueHandlerInit {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { publicKeyToProtobuf } from '@libp2p/crypto/keys';
|
|
2
2
|
import { InvalidMessageError, NotFoundError } from '@libp2p/interface';
|
|
3
3
|
import { Libp2pRecord } from '@libp2p/record';
|
|
4
|
-
import { PROVIDERS_VALIDITY } from
|
|
5
|
-
import { MessageType } from
|
|
6
|
-
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from
|
|
4
|
+
import { PROVIDERS_VALIDITY } from "../../constants.js";
|
|
5
|
+
import { MessageType } from "../../message/dht.js";
|
|
6
|
+
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from "../../utils.js";
|
|
7
7
|
export class GetValueHandler {
|
|
8
8
|
peerStore;
|
|
9
9
|
datastore;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Message } from '../../message/dht.
|
|
2
|
-
import type { DHTMessageHandler } from '../index.
|
|
1
|
+
import type { Message } from '../../message/dht.ts';
|
|
2
|
+
import type { DHTMessageHandler } from '../index.ts';
|
|
3
3
|
import type { ComponentLogger, PeerId } from '@libp2p/interface';
|
|
4
4
|
export interface PingComponents {
|
|
5
5
|
logger: ComponentLogger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Validators } from '../../index.
|
|
2
|
-
import type { Message } from '../../message/dht.
|
|
3
|
-
import type { DHTMessageHandler } from '../index.
|
|
1
|
+
import type { Validators } from '../../index.ts';
|
|
2
|
+
import type { Message } from '../../message/dht.ts';
|
|
3
|
+
import type { DHTMessageHandler } from '../index.ts';
|
|
4
4
|
import type { ComponentLogger, PeerId } from '@libp2p/interface';
|
|
5
5
|
import type { Datastore } from 'interface-datastore';
|
|
6
6
|
export interface PutValueHandlerInit {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InvalidMessageError } from '@libp2p/interface';
|
|
2
2
|
import { Libp2pRecord } from '@libp2p/record';
|
|
3
|
-
import { verifyRecord } from
|
|
4
|
-
import { bufferToRecordKey } from
|
|
3
|
+
import { verifyRecord } from "../../record/validators.js";
|
|
4
|
+
import { bufferToRecordKey } from "../../utils.js";
|
|
5
5
|
export class PutValueHandler {
|
|
6
6
|
components;
|
|
7
7
|
validators;
|
package/dist/src/rpc/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Message } from '../message/dht.
|
|
2
|
-
import type { PeerInfoMapper, Validators } from '../index.
|
|
3
|
-
import type { PeerRouting } from '../peer-routing/index.
|
|
4
|
-
import type { Providers } from '../providers.
|
|
1
|
+
import { Message } from '../message/dht.ts';
|
|
2
|
+
import type { PeerInfoMapper, Validators } from '../index.ts';
|
|
3
|
+
import type { PeerRouting } from '../peer-routing/index.ts';
|
|
4
|
+
import type { Providers } from '../providers.ts';
|
|
5
5
|
import type { FindNodeHandlerComponents } from './handlers/find-node.ts';
|
|
6
6
|
import type { GetProvidersHandlerComponents } from './handlers/get-providers.ts';
|
|
7
7
|
import type { GetValueHandlerComponents } from './handlers/get-value.ts';
|
|
8
8
|
import type { PutValueHandlerComponents } from './handlers/put-value.ts';
|
|
9
|
-
import type { RoutingTable } from '../routing-table/index.
|
|
9
|
+
import type { RoutingTable } from '../routing-table/index.ts';
|
|
10
10
|
import type { Metrics, PeerId, Connection, Stream } from '@libp2p/interface';
|
|
11
11
|
export interface DHTMessageHandler {
|
|
12
12
|
handle(peerId: PeerId, msg: Message): Promise<Message | undefined>;
|
package/dist/src/rpc/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InvalidMessageError, TimeoutError } from '@libp2p/interface';
|
|
2
2
|
import { pbStream } from '@libp2p/utils';
|
|
3
|
-
import { Message, MessageType } from
|
|
3
|
+
import { Message, MessageType } from "../message/dht.js";
|
|
4
4
|
import { AddProviderHandler } from "./handlers/add-provider.js";
|
|
5
5
|
import { FindNodeHandler } from "./handlers/find-node.js";
|
|
6
6
|
import { GetProvidersHandler } from "./handlers/get-providers.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/kad-dht",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0-29797a5bb",
|
|
4
4
|
"description": "JavaScript implementation of the Kad-DHT for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"doc-check": "aegir doc-check"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@libp2p/crypto": "
|
|
52
|
-
"@libp2p/interface": "
|
|
53
|
-
"@libp2p/interface-internal": "
|
|
54
|
-
"@libp2p/peer-collections": "
|
|
55
|
-
"@libp2p/peer-id": "
|
|
56
|
-
"@libp2p/ping": "
|
|
57
|
-
"@libp2p/record": "
|
|
58
|
-
"@libp2p/utils": "
|
|
51
|
+
"@libp2p/crypto": "5.1.18-29797a5bb",
|
|
52
|
+
"@libp2p/interface": "3.2.2-29797a5bb",
|
|
53
|
+
"@libp2p/interface-internal": "3.1.5-29797a5bb",
|
|
54
|
+
"@libp2p/peer-collections": "7.0.20-29797a5bb",
|
|
55
|
+
"@libp2p/peer-id": "6.0.9-29797a5bb",
|
|
56
|
+
"@libp2p/ping": "3.1.5-29797a5bb",
|
|
57
|
+
"@libp2p/record": "4.0.12-29797a5bb",
|
|
58
|
+
"@libp2p/utils": "7.2.1-29797a5bb",
|
|
59
59
|
"@multiformats/multiaddr": "^13.0.1",
|
|
60
60
|
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
61
61
|
"any-signal": "^4.1.1",
|
|
@@ -78,16 +78,16 @@
|
|
|
78
78
|
"race-signal": "^2.0.0",
|
|
79
79
|
"uint8-varint": "^2.0.4",
|
|
80
80
|
"uint8arraylist": "^2.4.8",
|
|
81
|
-
"uint8arrays": "^
|
|
81
|
+
"uint8arrays": "^6.1.1"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@libp2p/logger": "
|
|
85
|
-
"@libp2p/peer-store": "
|
|
84
|
+
"@libp2p/logger": "6.2.7-29797a5bb",
|
|
85
|
+
"@libp2p/peer-store": "12.0.20-29797a5bb",
|
|
86
86
|
"@types/lodash.random": "^3.2.9",
|
|
87
87
|
"@types/lodash.range": "^3.2.9",
|
|
88
88
|
"@types/sinon": "^21.0.1",
|
|
89
89
|
"@types/which": "^3.0.4",
|
|
90
|
-
"aegir": "^
|
|
90
|
+
"aegir": "^48.0.11",
|
|
91
91
|
"benchmark": "^2.1.4",
|
|
92
92
|
"datastore-core": "^11.0.1",
|
|
93
93
|
"delay": "^7.0.0",
|
|
@@ -6,22 +6,22 @@ import { pipe } from 'it-pipe'
|
|
|
6
6
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
7
7
|
import {
|
|
8
8
|
ALPHA
|
|
9
|
-
} from '../constants.
|
|
10
|
-
import { QueryError } from '../errors.
|
|
11
|
-
import { MessageType } from '../message/dht.
|
|
9
|
+
} from '../constants.ts'
|
|
10
|
+
import { QueryError } from '../errors.ts'
|
|
11
|
+
import { MessageType } from '../message/dht.ts'
|
|
12
12
|
import {
|
|
13
13
|
valueEvent,
|
|
14
14
|
queryErrorEvent
|
|
15
|
-
} from '../query/events.
|
|
16
|
-
import { bestRecord } from '../record/selectors.
|
|
17
|
-
import { verifyRecord } from '../record/validators.
|
|
18
|
-
import { createPutRecord, bufferToRecordKey } from '../utils.
|
|
19
|
-
import type { KadDHTComponents, Validators, Selectors, ValueEvent, QueryEvent } from '../index.
|
|
20
|
-
import type { Message } from '../message/dht.
|
|
21
|
-
import type { Network, SendMessageOptions } from '../network.
|
|
22
|
-
import type { PeerRouting } from '../peer-routing/index.
|
|
23
|
-
import type { QueryManager } from '../query/manager.
|
|
24
|
-
import type { QueryFunc } from '../query/types.
|
|
15
|
+
} from '../query/events.ts'
|
|
16
|
+
import { bestRecord } from '../record/selectors.ts'
|
|
17
|
+
import { verifyRecord } from '../record/validators.ts'
|
|
18
|
+
import { createPutRecord, bufferToRecordKey } from '../utils.ts'
|
|
19
|
+
import type { KadDHTComponents, Validators, Selectors, ValueEvent, QueryEvent } from '../index.ts'
|
|
20
|
+
import type { Message } from '../message/dht.ts'
|
|
21
|
+
import type { Network, SendMessageOptions } from '../network.ts'
|
|
22
|
+
import type { PeerRouting } from '../peer-routing/index.ts'
|
|
23
|
+
import type { QueryManager } from '../query/manager.ts'
|
|
24
|
+
import type { QueryFunc } from '../query/types.ts'
|
|
25
25
|
import type { AbortOptions, Logger, RoutingOptions } from '@libp2p/interface'
|
|
26
26
|
|
|
27
27
|
export interface ContentFetchingInit {
|
|
@@ -230,7 +230,7 @@ export class ContentFetching {
|
|
|
230
230
|
let i = 0
|
|
231
231
|
|
|
232
232
|
try {
|
|
233
|
-
i = bestRecord(this.selectors, key, records)
|
|
233
|
+
i = await bestRecord(this.selectors, key, records)
|
|
234
234
|
} catch (err: any) {
|
|
235
235
|
// Assume the first record if no selector available
|
|
236
236
|
if (err.name !== 'InvalidParametersError') {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
2
2
|
import { Queue } from '@libp2p/utils'
|
|
3
3
|
import { pushable } from 'it-pushable'
|
|
4
|
-
import { ALPHA } from '../constants.
|
|
5
|
-
import { MessageType } from '../message/dht.
|
|
6
|
-
import { toPbPeerInfo } from '../message/utils.
|
|
4
|
+
import { ALPHA } from '../constants.ts'
|
|
5
|
+
import { MessageType } from '../message/dht.ts'
|
|
6
|
+
import { toPbPeerInfo } from '../message/utils.ts'
|
|
7
7
|
import {
|
|
8
8
|
queryErrorEvent,
|
|
9
9
|
peerResponseEvent,
|
|
10
10
|
providerEvent
|
|
11
|
-
} from '../query/events.
|
|
12
|
-
import type { FinalPeerEvent, KadDHTComponents, PeerResponseEvent, ProviderEvent, QueryEvent } from '../index.
|
|
13
|
-
import type { Message } from '../message/dht.
|
|
14
|
-
import type { Network } from '../network.
|
|
15
|
-
import type { PeerRouting } from '../peer-routing/index.
|
|
16
|
-
import type { Providers } from '../providers.
|
|
17
|
-
import type { QueryManager } from '../query/manager.
|
|
18
|
-
import type { QueryFunc } from '../query/types.
|
|
19
|
-
import type { RoutingTable } from '../routing-table/index.
|
|
11
|
+
} from '../query/events.ts'
|
|
12
|
+
import type { FinalPeerEvent, KadDHTComponents, PeerResponseEvent, ProviderEvent, QueryEvent } from '../index.ts'
|
|
13
|
+
import type { Message } from '../message/dht.ts'
|
|
14
|
+
import type { Network } from '../network.ts'
|
|
15
|
+
import type { PeerRouting } from '../peer-routing/index.ts'
|
|
16
|
+
import type { Providers } from '../providers.ts'
|
|
17
|
+
import type { QueryManager } from '../query/manager.ts'
|
|
18
|
+
import type { QueryFunc } from '../query/types.ts'
|
|
19
|
+
import type { RoutingTable } from '../routing-table/index.ts'
|
|
20
20
|
import type { Logger, PeerInfo, RoutingOptions } from '@libp2p/interface'
|
|
21
21
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
22
22
|
import type { CID } from 'multiformats/cid'
|
package/src/index.ts
CHANGED
|
@@ -326,6 +326,16 @@ export interface KadDHT {
|
|
|
326
326
|
*/
|
|
327
327
|
readonly d: number
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Validators validate DHT records that are found
|
|
331
|
+
*/
|
|
332
|
+
readonly validators: Record<string, ValidateFn>
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* When multiple records for a DHT key are found, selectors choose one record
|
|
336
|
+
*/
|
|
337
|
+
readonly selectors: Record<string, SelectFn>
|
|
338
|
+
|
|
329
339
|
/**
|
|
330
340
|
* Get a value from the DHT, the final ValueEvent will be the best value
|
|
331
341
|
*/
|
|
@@ -387,13 +397,17 @@ export interface SingleKadDHT extends KadDHT {
|
|
|
387
397
|
* A selector function takes a DHT key and a list of records and returns the
|
|
388
398
|
* index of the best record in the list
|
|
389
399
|
*/
|
|
390
|
-
export interface SelectFn {
|
|
400
|
+
export interface SelectFn {
|
|
401
|
+
(key: Uint8Array, records: Uint8Array[]): number | Promise<number>
|
|
402
|
+
}
|
|
391
403
|
|
|
392
404
|
/**
|
|
393
405
|
* A validator function takes a DHT key and the value of the record for that key
|
|
394
406
|
* and throws if the record is invalid
|
|
395
407
|
*/
|
|
396
|
-
export interface ValidateFn {
|
|
408
|
+
export interface ValidateFn {
|
|
409
|
+
(key: Uint8Array, value: Uint8Array, options?: AbortOptions): void | Promise<void>
|
|
410
|
+
}
|
|
397
411
|
|
|
398
412
|
/**
|
|
399
413
|
* Selectors are a map of key prefixes to selector functions
|
package/src/kad-dht.ts
CHANGED
|
@@ -126,13 +126,13 @@ export class KadDHT extends TypedEventEmitter<PeerDiscoveryEvents> implements Ka
|
|
|
126
126
|
public providers: Providers
|
|
127
127
|
public network: Network
|
|
128
128
|
public peerRouting: KADDHTPeerRouting
|
|
129
|
+
public readonly validators: Validators
|
|
130
|
+
public readonly selectors: Selectors
|
|
129
131
|
|
|
130
132
|
public readonly components: KadDHTComponents
|
|
131
133
|
private readonly log: Logger
|
|
132
134
|
private running: boolean
|
|
133
135
|
private clientMode: boolean
|
|
134
|
-
private readonly validators: Validators
|
|
135
|
-
private readonly selectors: Selectors
|
|
136
136
|
private readonly queryManager: QueryManager
|
|
137
137
|
private readonly contentFetching: ContentFetching
|
|
138
138
|
private readonly contentRouting: KADDHTContentRouting
|
|
@@ -3,22 +3,22 @@ import { InvalidPublicKeyError, NotFoundError } from '@libp2p/interface'
|
|
|
3
3
|
import { peerIdFromPublicKey, peerIdFromMultihash } from '@libp2p/peer-id'
|
|
4
4
|
import { Libp2pRecord } from '@libp2p/record'
|
|
5
5
|
import * as Digest from 'multiformats/hashes/digest'
|
|
6
|
-
import { QueryError, InvalidRecordError } from '../errors.
|
|
7
|
-
import { MessageType } from '../message/dht.
|
|
8
|
-
import { PeerDistanceList } from '../peer-distance-list.
|
|
6
|
+
import { QueryError, InvalidRecordError } from '../errors.ts'
|
|
7
|
+
import { MessageType } from '../message/dht.ts'
|
|
8
|
+
import { PeerDistanceList } from '../peer-distance-list.ts'
|
|
9
9
|
import {
|
|
10
10
|
queryErrorEvent,
|
|
11
11
|
finalPeerEvent,
|
|
12
12
|
valueEvent
|
|
13
|
-
} from '../query/events.
|
|
14
|
-
import { verifyRecord } from '../record/validators.
|
|
15
|
-
import { convertBuffer, keyForPublicKey } from '../utils.
|
|
16
|
-
import type { DHTRecord, FinalPeerEvent, QueryEvent, Validators } from '../index.
|
|
17
|
-
import type { Message } from '../message/dht.
|
|
18
|
-
import type { Network, SendMessageOptions } from '../network.
|
|
19
|
-
import type { QueryManager, QueryOptions } from '../query/manager.
|
|
20
|
-
import type { QueryFunc } from '../query/types.
|
|
21
|
-
import type { RoutingTable } from '../routing-table/index.
|
|
13
|
+
} from '../query/events.ts'
|
|
14
|
+
import { verifyRecord } from '../record/validators.ts'
|
|
15
|
+
import { convertBuffer, keyForPublicKey } from '../utils.ts'
|
|
16
|
+
import type { DHTRecord, FinalPeerEvent, QueryEvent, Validators } from '../index.ts'
|
|
17
|
+
import type { Message } from '../message/dht.ts'
|
|
18
|
+
import type { Network, SendMessageOptions } from '../network.ts'
|
|
19
|
+
import type { QueryManager, QueryOptions } from '../query/manager.ts'
|
|
20
|
+
import type { QueryFunc } from '../query/types.ts'
|
|
21
|
+
import type { RoutingTable } from '../routing-table/index.ts'
|
|
22
22
|
import type { GetClosestPeersOptions } from '../routing-table/k-bucket.ts'
|
|
23
23
|
import type { ComponentLogger, Logger, Metrics, PeerId, PeerInfo, PeerStore, RoutingOptions } from '@libp2p/interface'
|
|
24
24
|
import type { AbortOptions } from 'it-pushable'
|
package/src/query/events.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageType, SendQueryEvent, PeerResponseEvent, AddPeerEvent, ValueEvent, ProviderEvent, QueryErrorEvent, FinalPeerEvent, DisjointPath, PathEndedEvent, DialPeerEvent } from '../index.
|
|
1
|
+
import type { MessageType, SendQueryEvent, PeerResponseEvent, AddPeerEvent, ValueEvent, ProviderEvent, QueryErrorEvent, FinalPeerEvent, DisjointPath, PathEndedEvent, DialPeerEvent } from '../index.ts'
|
|
2
2
|
import type { PeerId, PeerInfo } from '@libp2p/interface'
|
|
3
3
|
import type { Libp2pRecord } from '@libp2p/record'
|
|
4
4
|
import type { ProgressOptions } from 'progress-events'
|
package/src/query/manager.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { raceSignal } from 'race-signal'
|
|
|
7
7
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
8
8
|
import {
|
|
9
9
|
ALPHA, K, DEFAULT_QUERY_TIMEOUT
|
|
10
|
-
} from '../constants.
|
|
11
|
-
import { convertBuffer } from '../utils.
|
|
10
|
+
} from '../constants.ts'
|
|
11
|
+
import { convertBuffer } from '../utils.ts'
|
|
12
12
|
import { queryPath } from './query-path.ts'
|
|
13
13
|
import type { QueryFunc } from './types.ts'
|
|
14
|
-
import type { QueryEvent } from '../index.
|
|
15
|
-
import type { RoutingTable } from '../routing-table/index.
|
|
14
|
+
import type { QueryEvent } from '../index.ts'
|
|
15
|
+
import type { RoutingTable } from '../routing-table/index.ts'
|
|
16
16
|
import type { ComponentLogger, Metrics, PeerId, RoutingOptions, Startable } from '@libp2p/interface'
|
|
17
17
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
18
18
|
import type { DeferredPromise } from 'p-defer'
|
package/src/query/query-path.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Queue } from '@libp2p/utils'
|
|
|
3
3
|
import { pushable } from 'it-pushable'
|
|
4
4
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
5
5
|
import { xorCompare as uint8ArrayXorCompare } from 'uint8arrays/xor-compare'
|
|
6
|
-
import { convertPeerId, convertBuffer } from '../utils.
|
|
6
|
+
import { convertPeerId, convertBuffer } from '../utils.ts'
|
|
7
7
|
import { pathEndedEvent, queryErrorEvent } from './events.ts'
|
|
8
|
-
import type { QueryEvent } from '../index.
|
|
9
|
-
import type { QueryFunc } from '../query/types.
|
|
8
|
+
import type { QueryEvent } from '../index.ts'
|
|
9
|
+
import type { QueryFunc } from '../query/types.ts'
|
|
10
10
|
import type { Logger, PeerId, RoutingOptions, AbortOptions, PeerInfo } from '@libp2p/interface'
|
|
11
11
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
12
12
|
import type { Filter } from '@libp2p/utils'
|
package/src/query/types.ts
CHANGED
package/src/record/selectors.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
2
2
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
3
|
-
import { MissingSelectorError } from '../errors.
|
|
4
|
-
import type { Selectors } from '../index.
|
|
3
|
+
import { MissingSelectorError } from '../errors.ts'
|
|
4
|
+
import type { Selectors } from '../index.ts'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Select the best record out of the given records
|
|
8
8
|
*/
|
|
9
|
-
export function bestRecord (selectors: Selectors, k: Uint8Array, records: Uint8Array[]): number {
|
|
9
|
+
export async function bestRecord (selectors: Selectors, k: Uint8Array, records: Uint8Array[]): Promise<number> {
|
|
10
10
|
if (records.length === 0) {
|
|
11
11
|
throw new InvalidParametersError('No records given')
|
|
12
12
|
}
|
package/src/record/validators.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys'
|
|
|
2
2
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
3
3
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
4
4
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
5
|
-
import type { Validators } from '../index.
|
|
5
|
+
import type { Validators } from '../index.ts'
|
|
6
6
|
import type { Libp2pRecord } from '@libp2p/record'
|
|
7
7
|
import type { AbortOptions } from 'it-pushable'
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
2
|
-
import { KEEP_ALIVE_TAG } from '../constants.
|
|
3
|
-
import { PeerDistanceList } from '../peer-distance-list.
|
|
4
|
-
import { convertPeerId } from '../utils.
|
|
2
|
+
import { KEEP_ALIVE_TAG } from '../constants.ts'
|
|
3
|
+
import { PeerDistanceList } from '../peer-distance-list.ts'
|
|
4
|
+
import { convertPeerId } from '../utils.ts'
|
|
5
5
|
import type { RoutingTable } from './index.ts'
|
|
6
6
|
import type { ComponentLogger, Logger, Metrics, PeerId, PeerStore, Startable } from '@libp2p/interface'
|
|
7
7
|
|
|
@@ -3,11 +3,11 @@ import { AdaptiveTimeout, PeerQueue } from '@libp2p/utils'
|
|
|
3
3
|
import { anySignal } from 'any-signal'
|
|
4
4
|
import parallel from 'it-parallel'
|
|
5
5
|
import { TypedEventEmitter, setMaxListeners } from 'main-event'
|
|
6
|
-
import * as utils from '../utils.
|
|
6
|
+
import * as utils from '../utils.ts'
|
|
7
7
|
import { ClosestPeers } from './closest-peers.ts'
|
|
8
8
|
import { KBucket, isLeafBucket } from './k-bucket.ts'
|
|
9
9
|
import type { Bucket, GetClosestPeersOptions, LeafBucket, Peer } from './k-bucket.ts'
|
|
10
|
-
import type { Network } from '../network.
|
|
10
|
+
import type { Network } from '../network.ts'
|
|
11
11
|
import type { AbortOptions, ComponentLogger, CounterGroup, Logger, Metric, Metrics, PeerId, PeerStore, Startable, Stream } from '@libp2p/interface'
|
|
12
12
|
import type { Ping } from '@libp2p/ping'
|
|
13
13
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils'
|
|
@@ -3,8 +3,8 @@ import map from 'it-map'
|
|
|
3
3
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
4
4
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
5
5
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
6
|
-
import { PeerDistanceList } from '../peer-distance-list.
|
|
7
|
-
import { convertPeerId } from '../utils.
|
|
6
|
+
import { PeerDistanceList } from '../peer-distance-list.ts'
|
|
7
|
+
import { convertPeerId } from '../utils.ts'
|
|
8
8
|
import { KBUCKET_SIZE, LAST_PING_THRESHOLD, PING_OLD_CONTACT_COUNT, PREFIX_LENGTH } from './index.ts'
|
|
9
9
|
import type { PeerId, AbortOptions, Metrics } from '@libp2p/interface'
|
|
10
10
|
|
|
@@ -6,10 +6,10 @@ import { setMaxListeners } from 'main-event'
|
|
|
6
6
|
import * as Digest from 'multiformats/hashes/digest'
|
|
7
7
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
8
8
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
9
|
-
import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constants.
|
|
9
|
+
import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constants.ts'
|
|
10
10
|
import GENERATED_PREFIXES from './generated-prefix-list.ts'
|
|
11
11
|
import type { RoutingTable } from './index.ts'
|
|
12
|
-
import type { PeerRouting } from '../peer-routing/index.
|
|
12
|
+
import type { PeerRouting } from '../peer-routing/index.ts'
|
|
13
13
|
import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface'
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -3,9 +3,9 @@ import { peerIdFromMultihash } from '@libp2p/peer-id'
|
|
|
3
3
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
4
4
|
import { CID } from 'multiformats/cid'
|
|
5
5
|
import * as Digest from 'multiformats/hashes/digest'
|
|
6
|
-
import type { Message } from '../../message/dht.
|
|
7
|
-
import type { Providers } from '../../providers.
|
|
8
|
-
import type { DHTMessageHandler } from '../index.
|
|
6
|
+
import type { Message } from '../../message/dht.ts'
|
|
7
|
+
import type { Providers } from '../../providers.ts'
|
|
8
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
9
9
|
import type { ComponentLogger, Logger, PeerId, PeerStore } from '@libp2p/interface'
|
|
10
10
|
|
|
11
11
|
export interface AddProviderComponents {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InvalidMessageError } from '@libp2p/interface'
|
|
2
2
|
import { CODE_P2P } from '@multiformats/multiaddr'
|
|
3
3
|
import { equals as uint8ArrayEquals } from 'uint8arrays'
|
|
4
|
-
import { MessageType } from '../../message/dht.
|
|
5
|
-
import type { PeerInfoMapper } from '../../index.
|
|
6
|
-
import type { Message } from '../../message/dht.
|
|
7
|
-
import type { PeerRouting } from '../../peer-routing/index.
|
|
8
|
-
import type { DHTMessageHandler } from '../index.
|
|
4
|
+
import { MessageType } from '../../message/dht.ts'
|
|
5
|
+
import type { PeerInfoMapper } from '../../index.ts'
|
|
6
|
+
import type { Message } from '../../message/dht.ts'
|
|
7
|
+
import type { PeerRouting } from '../../peer-routing/index.ts'
|
|
8
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
9
9
|
import type { ComponentLogger, Logger, PeerId, PeerInfo } from '@libp2p/interface'
|
|
10
10
|
import type { AddressManager } from '@libp2p/interface-internal'
|
|
11
11
|
|
|
@@ -2,12 +2,12 @@ import { InvalidMessageError } from '@libp2p/interface'
|
|
|
2
2
|
import all from 'it-all'
|
|
3
3
|
import map from 'it-map'
|
|
4
4
|
import { CID } from 'multiformats/cid'
|
|
5
|
-
import { MessageType } from '../../message/dht.
|
|
6
|
-
import type { PeerInfoMapper } from '../../index.
|
|
7
|
-
import type { Message } from '../../message/dht.
|
|
8
|
-
import type { PeerRouting } from '../../peer-routing/index.
|
|
9
|
-
import type { Providers } from '../../providers.
|
|
10
|
-
import type { DHTMessageHandler } from '../index.
|
|
5
|
+
import { MessageType } from '../../message/dht.ts'
|
|
6
|
+
import type { PeerInfoMapper } from '../../index.ts'
|
|
7
|
+
import type { Message } from '../../message/dht.ts'
|
|
8
|
+
import type { PeerRouting } from '../../peer-routing/index.ts'
|
|
9
|
+
import type { Providers } from '../../providers.ts'
|
|
10
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
11
11
|
import type { ComponentLogger, Logger, PeerId, PeerInfo, PeerStore } from '@libp2p/interface'
|
|
12
12
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
13
13
|
|
|
@@ -3,12 +3,12 @@ import { InvalidMessageError, NotFoundError } from '@libp2p/interface'
|
|
|
3
3
|
import { Libp2pRecord } from '@libp2p/record'
|
|
4
4
|
import {
|
|
5
5
|
PROVIDERS_VALIDITY
|
|
6
|
-
} from '../../constants.
|
|
7
|
-
import { MessageType } from '../../message/dht.
|
|
8
|
-
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.
|
|
9
|
-
import type { Message } from '../../message/dht.
|
|
10
|
-
import type { PeerRouting } from '../../peer-routing/index.
|
|
11
|
-
import type { DHTMessageHandler } from '../index.
|
|
6
|
+
} from '../../constants.ts'
|
|
7
|
+
import { MessageType } from '../../message/dht.ts'
|
|
8
|
+
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.ts'
|
|
9
|
+
import type { Message } from '../../message/dht.ts'
|
|
10
|
+
import type { PeerRouting } from '../../peer-routing/index.ts'
|
|
11
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
12
12
|
import type { ComponentLogger, Logger, PeerId, PeerStore } from '@libp2p/interface'
|
|
13
13
|
import type { Datastore } from 'interface-datastore'
|
|
14
14
|
|
package/src/rpc/handlers/ping.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Message } from '../../message/dht.
|
|
2
|
-
import type { DHTMessageHandler } from '../index.
|
|
1
|
+
import type { Message } from '../../message/dht.ts'
|
|
2
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
3
3
|
import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface'
|
|
4
4
|
|
|
5
5
|
export interface PingComponents {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { InvalidMessageError } from '@libp2p/interface'
|
|
2
2
|
import { Libp2pRecord } from '@libp2p/record'
|
|
3
|
-
import { verifyRecord } from '../../record/validators.
|
|
4
|
-
import { bufferToRecordKey } from '../../utils.
|
|
5
|
-
import type { Validators } from '../../index.
|
|
6
|
-
import type { Message } from '../../message/dht.
|
|
7
|
-
import type { DHTMessageHandler } from '../index.
|
|
3
|
+
import { verifyRecord } from '../../record/validators.ts'
|
|
4
|
+
import { bufferToRecordKey } from '../../utils.ts'
|
|
5
|
+
import type { Validators } from '../../index.ts'
|
|
6
|
+
import type { Message } from '../../message/dht.ts'
|
|
7
|
+
import type { DHTMessageHandler } from '../index.ts'
|
|
8
8
|
import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface'
|
|
9
9
|
import type { Datastore } from 'interface-datastore'
|
|
10
10
|
|
package/src/rpc/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { InvalidMessageError, TimeoutError } from '@libp2p/interface'
|
|
2
2
|
import { pbStream } from '@libp2p/utils'
|
|
3
|
-
import { Message, MessageType } from '../message/dht.
|
|
3
|
+
import { Message, MessageType } from '../message/dht.ts'
|
|
4
4
|
import { AddProviderHandler } from './handlers/add-provider.ts'
|
|
5
5
|
import { FindNodeHandler } from './handlers/find-node.ts'
|
|
6
6
|
import { GetProvidersHandler } from './handlers/get-providers.ts'
|
|
7
7
|
import { GetValueHandler } from './handlers/get-value.ts'
|
|
8
8
|
import { PingHandler } from './handlers/ping.ts'
|
|
9
9
|
import { PutValueHandler } from './handlers/put-value.ts'
|
|
10
|
-
import type { PeerInfoMapper, Validators } from '../index.
|
|
11
|
-
import type { PeerRouting } from '../peer-routing/index.
|
|
12
|
-
import type { Providers } from '../providers.
|
|
10
|
+
import type { PeerInfoMapper, Validators } from '../index.ts'
|
|
11
|
+
import type { PeerRouting } from '../peer-routing/index.ts'
|
|
12
|
+
import type { Providers } from '../providers.ts'
|
|
13
13
|
import type { FindNodeHandlerComponents } from './handlers/find-node.ts'
|
|
14
14
|
import type { GetProvidersHandlerComponents } from './handlers/get-providers.ts'
|
|
15
15
|
import type { GetValueHandlerComponents } from './handlers/get-value.ts'
|
|
16
16
|
import type { PutValueHandlerComponents } from './handlers/put-value.ts'
|
|
17
|
-
import type { RoutingTable } from '../routing-table/index.
|
|
17
|
+
import type { RoutingTable } from '../routing-table/index.ts'
|
|
18
18
|
import type { CounterGroup, Logger, Metrics, PeerId, MetricGroup, Connection, Stream } from '@libp2p/interface'
|
|
19
19
|
|
|
20
20
|
export interface DHTMessageHandler {
|