@libp2p/kad-dht 16.2.0 → 16.2.2-8f7e9264e
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 -4
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +3 -3
- package/dist/src/kad-dht.d.ts +5 -5
- package/dist/src/kad-dht.js +16 -16
- package/dist/src/message/utils.d.ts +1 -1
- package/dist/src/network.d.ts +2 -2
- package/dist/src/network.js +3 -3
- package/dist/src/peer-distance-list.d.ts +1 -1
- package/dist/src/peer-distance-list.js +1 -1
- package/dist/src/providers.js +1 -1
- package/dist/src/query/manager.d.ts +1 -1
- package/dist/src/query/manager.js +1 -1
- package/dist/src/query/query-path.js +1 -1
- package/dist/src/query-self.d.ts +2 -2
- package/dist/src/query-self.js +2 -2
- package/dist/src/reprovider.d.ts +2 -2
- package/dist/src/reprovider.js +2 -2
- package/dist/src/routing-table/closest-peers.d.ts +1 -1
- package/dist/src/routing-table/index.d.ts +2 -2
- package/dist/src/routing-table/index.js +2 -2
- package/dist/src/routing-table/k-bucket.js +1 -1
- package/dist/src/routing-table/refresh.d.ts +1 -1
- package/dist/src/routing-table/refresh.js +1 -1
- package/dist/src/rpc/index.d.ts +4 -4
- package/dist/src/rpc/index.js +6 -6
- package/dist/src/topology-listener.d.ts +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/package.json +15 -14
- package/src/index.ts +3 -3
- package/src/kad-dht.ts +17 -17
- package/src/message/utils.ts +1 -1
- package/src/network.ts +4 -4
- package/src/peer-distance-list.ts +2 -2
- package/src/providers.ts +1 -1
- package/src/query/manager.ts +2 -2
- package/src/query/query-path.ts +1 -1
- package/src/query-self.ts +4 -4
- package/src/reprovider.ts +4 -4
- package/src/routing-table/closest-peers.ts +1 -1
- package/src/routing-table/index.ts +3 -3
- package/src/routing-table/k-bucket.ts +1 -1
- package/src/routing-table/refresh.ts +2 -2
- package/src/rpc/index.ts +10 -10
- package/src/topology-listener.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/typedoc-urls.json +0 -65
package/dist/src/index.d.ts
CHANGED
|
@@ -131,8 +131,8 @@
|
|
|
131
131
|
* console.info(peerInfo) // peer id, multiaddrs
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
|
-
import { MessageType } from './message/dht.
|
|
135
|
-
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from './utils.
|
|
134
|
+
import { MessageType } from './message/dht.ts';
|
|
135
|
+
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from './utils.ts';
|
|
136
136
|
import type { Libp2pEvents, ComponentLogger, Metrics, PeerId, PeerInfo, PeerStore, RoutingOptions, PrivateKey, AbortOptions } from '@libp2p/interface';
|
|
137
137
|
import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal';
|
|
138
138
|
import type { Ping } from '@libp2p/ping';
|
package/dist/src/index.js
CHANGED
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
* console.info(peerInfo) // peer id, multiaddrs
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
|
-
import { KadDHT as KadDHTClass } from
|
|
135
|
-
import { MessageType } from
|
|
136
|
-
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from
|
|
134
|
+
import { KadDHT as KadDHTClass } from "./kad-dht.js";
|
|
135
|
+
import { MessageType } from "./message/dht.js";
|
|
136
|
+
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from "./utils.js";
|
|
137
137
|
export { Libp2pRecord as Record } from '@libp2p/record';
|
|
138
138
|
export { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper };
|
|
139
139
|
/**
|
package/dist/src/kad-dht.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { contentRoutingSymbol, peerDiscoverySymbol, peerRoutingSymbol, serviceCapabilities, serviceDependencies } from '@libp2p/interface';
|
|
2
2
|
import { TypedEventEmitter } from 'main-event';
|
|
3
|
-
import { Network } from './network.
|
|
4
|
-
import { PeerRouting as KADDHTPeerRouting } from './peer-routing/index.
|
|
5
|
-
import { Providers } from './providers.
|
|
6
|
-
import { RoutingTable } from './routing-table/index.
|
|
7
|
-
import type { KadDHTComponents, KadDHTInit, KadDHT as KadDHTInterface, QueryEvent, SetModeOptions } from './index.
|
|
3
|
+
import { Network } from './network.ts';
|
|
4
|
+
import { PeerRouting as KADDHTPeerRouting } from './peer-routing/index.ts';
|
|
5
|
+
import { Providers } from './providers.ts';
|
|
6
|
+
import { RoutingTable } from './routing-table/index.ts';
|
|
7
|
+
import type { KadDHTComponents, KadDHTInit, KadDHT as KadDHTInterface, QueryEvent, SetModeOptions } from './index.ts';
|
|
8
8
|
import type { ContentRouting, CounterGroup, MetricGroup, PeerDiscovery, PeerDiscoveryEvents, PeerId, PeerInfo, PeerRouting, RoutingOptions, Startable } from '@libp2p/interface';
|
|
9
9
|
import type { AbortOptions } from 'it-pushable';
|
|
10
10
|
import type { CID } from 'multiformats/cid';
|
package/dist/src/kad-dht.js
CHANGED
|
@@ -4,22 +4,22 @@ import { Circuit } from '@multiformats/multiaddr-matcher';
|
|
|
4
4
|
import drain from 'it-drain';
|
|
5
5
|
import { setMaxListeners, TypedEventEmitter } from 'main-event';
|
|
6
6
|
import pDefer from 'p-defer';
|
|
7
|
-
import { ALPHA, ON_PEER_CONNECT_TIMEOUT, PROTOCOL } from
|
|
8
|
-
import { ContentFetching } from
|
|
9
|
-
import { ContentRouting as KADDHTContentRouting } from
|
|
10
|
-
import { Network } from
|
|
11
|
-
import { PeerRouting as KADDHTPeerRouting } from
|
|
12
|
-
import { Providers } from
|
|
13
|
-
import { QueryManager } from
|
|
14
|
-
import { QuerySelf } from
|
|
15
|
-
import { selectors as recordSelectors } from
|
|
16
|
-
import { validators as recordValidators } from
|
|
17
|
-
import { Reprovider } from
|
|
18
|
-
import { KBUCKET_SIZE, RoutingTable } from
|
|
19
|
-
import { RoutingTableRefresh } from
|
|
20
|
-
import { RPC } from
|
|
21
|
-
import { TopologyListener } from
|
|
22
|
-
import { removePrivateAddressesMapper, timeOperationGenerator } from
|
|
7
|
+
import { ALPHA, ON_PEER_CONNECT_TIMEOUT, PROTOCOL } from "./constants.js";
|
|
8
|
+
import { ContentFetching } from "./content-fetching/index.js";
|
|
9
|
+
import { ContentRouting as KADDHTContentRouting } from "./content-routing/index.js";
|
|
10
|
+
import { Network } from "./network.js";
|
|
11
|
+
import { PeerRouting as KADDHTPeerRouting } from "./peer-routing/index.js";
|
|
12
|
+
import { Providers } from "./providers.js";
|
|
13
|
+
import { QueryManager } from "./query/manager.js";
|
|
14
|
+
import { QuerySelf } from "./query-self.js";
|
|
15
|
+
import { selectors as recordSelectors } from "./record/selectors.js";
|
|
16
|
+
import { validators as recordValidators } from "./record/validators.js";
|
|
17
|
+
import { Reprovider } from "./reprovider.js";
|
|
18
|
+
import { KBUCKET_SIZE, RoutingTable } from "./routing-table/index.js";
|
|
19
|
+
import { RoutingTableRefresh } from "./routing-table/refresh.js";
|
|
20
|
+
import { RPC } from "./rpc/index.js";
|
|
21
|
+
import { TopologyListener } from "./topology-listener.js";
|
|
22
|
+
import { removePrivateAddressesMapper, timeOperationGenerator } from "./utils.js";
|
|
23
23
|
/**
|
|
24
24
|
* Wrapper class to convert events into returned values
|
|
25
25
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PeerInfo as PBPeerInfo, ConnectionType } from './dht.
|
|
1
|
+
import type { PeerInfo as PBPeerInfo, ConnectionType } from './dht.ts';
|
|
2
2
|
import type { PeerInfo } from '@libp2p/interface';
|
|
3
3
|
export declare function toPbPeerInfo(peer: PeerInfo, connection?: ConnectionType): PBPeerInfo;
|
|
4
4
|
export declare function fromPbPeerInfo(peer: PBPeerInfo): PeerInfo;
|
package/dist/src/network.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'main-event';
|
|
2
|
-
import { Message } from './message/dht.
|
|
3
|
-
import type { DisjointPath, KadDHTComponents, QueryEvent } from './index.
|
|
2
|
+
import { Message } from './message/dht.ts';
|
|
3
|
+
import type { DisjointPath, KadDHTComponents, QueryEvent } from './index.ts';
|
|
4
4
|
import type { AbortOptions, Stream, PeerId, PeerInfo, Startable, RoutingOptions } from '@libp2p/interface';
|
|
5
5
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils';
|
|
6
6
|
export interface NetworkInit {
|
package/dist/src/network.js
CHANGED
|
@@ -2,9 +2,9 @@ import { InvalidParametersError } from '@libp2p/interface';
|
|
|
2
2
|
import { Libp2pRecord } from '@libp2p/record';
|
|
3
3
|
import { AdaptiveTimeout, pbStream } from '@libp2p/utils';
|
|
4
4
|
import { TypedEventEmitter } from 'main-event';
|
|
5
|
-
import { Message } from
|
|
6
|
-
import { fromPbPeerInfo } from
|
|
7
|
-
import { sendQueryEvent, peerResponseEvent, queryErrorEvent, dialPeerEvent } from
|
|
5
|
+
import { Message } from "./message/dht.js";
|
|
6
|
+
import { fromPbPeerInfo } from "./message/utils.js";
|
|
7
|
+
import { sendQueryEvent, peerResponseEvent, queryErrorEvent, dialPeerEvent } from "./query/events.js";
|
|
8
8
|
/**
|
|
9
9
|
* Handle network operations for the dht
|
|
10
10
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor';
|
|
2
2
|
import { xorCompare as uint8ArrayXorCompare } from 'uint8arrays/xor-compare';
|
|
3
|
-
import { convertPeerId } from
|
|
3
|
+
import { convertPeerId } from "./utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Maintains a list of peerIds sorted by distance from a DHT key.
|
|
6
6
|
*/
|
package/dist/src/providers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PeerMap } from '@libp2p/peer-collections';
|
|
2
2
|
import * as varint from 'uint8-varint';
|
|
3
|
-
import { parseProviderKey, readProviderTime, toProviderKey } from
|
|
3
|
+
import { parseProviderKey, readProviderTime, toProviderKey } from "./utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Provides a mechanism to add and remove provider records from the datastore
|
|
6
6
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryFunc } from './types.
|
|
1
|
+
import type { QueryFunc } from './types.ts';
|
|
2
2
|
import type { QueryEvent } from '../index.js';
|
|
3
3
|
import type { RoutingTable } from '../routing-table/index.js';
|
|
4
4
|
import type { ComponentLogger, Metrics, PeerId, RoutingOptions, Startable } from '@libp2p/interface';
|
|
@@ -7,7 +7,7 @@ import { raceSignal } from 'race-signal';
|
|
|
7
7
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
8
8
|
import { ALPHA, K, DEFAULT_QUERY_TIMEOUT } from '../constants.js';
|
|
9
9
|
import { convertBuffer } from '../utils.js';
|
|
10
|
-
import { queryPath } from
|
|
10
|
+
import { queryPath } from "./query-path.js";
|
|
11
11
|
/**
|
|
12
12
|
* Keeps track of all running queries
|
|
13
13
|
*/
|
|
@@ -4,7 +4,7 @@ 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
6
|
import { convertPeerId, convertBuffer } from '../utils.js';
|
|
7
|
-
import { pathEndedEvent, queryErrorEvent } from
|
|
7
|
+
import { pathEndedEvent, queryErrorEvent } from "./events.js";
|
|
8
8
|
/**
|
|
9
9
|
* Walks a path through the DHT, calling the passed query function for
|
|
10
10
|
* every peer encountered that we have not seen before
|
package/dist/src/query-self.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OperationMetrics } from './kad-dht.
|
|
2
|
-
import type { PeerRouting } from './peer-routing/index.
|
|
1
|
+
import type { OperationMetrics } from './kad-dht.ts';
|
|
2
|
+
import type { PeerRouting } from './peer-routing/index.ts';
|
|
3
3
|
import type { ComponentLogger, Metrics, PeerId, Startable } from '@libp2p/interface';
|
|
4
4
|
import type { DeferredPromise } from 'p-defer';
|
|
5
5
|
export interface QuerySelfInit {
|
package/dist/src/query-self.js
CHANGED
|
@@ -4,8 +4,8 @@ import { pipe } from 'it-pipe';
|
|
|
4
4
|
import take from 'it-take';
|
|
5
5
|
import { setMaxListeners } from 'main-event';
|
|
6
6
|
import pDefer from 'p-defer';
|
|
7
|
-
import { QUERY_SELF_INTERVAL, QUERY_SELF_TIMEOUT, K, QUERY_SELF_INITIAL_INTERVAL } from
|
|
8
|
-
import { timeOperationMethod } from
|
|
7
|
+
import { QUERY_SELF_INTERVAL, QUERY_SELF_TIMEOUT, K, QUERY_SELF_INITIAL_INTERVAL } from "./constants.js";
|
|
8
|
+
import { timeOperationMethod } from "./utils.js";
|
|
9
9
|
/**
|
|
10
10
|
* Receives notifications of new peers joining the network that support the DHT protocol
|
|
11
11
|
*/
|
package/dist/src/reprovider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'main-event';
|
|
2
|
-
import type { ContentRouting } from './content-routing/index.
|
|
3
|
-
import type { OperationMetrics } from './kad-dht.
|
|
2
|
+
import type { ContentRouting } from './content-routing/index.ts';
|
|
3
|
+
import type { OperationMetrics } from './kad-dht.ts';
|
|
4
4
|
import type { ComponentLogger, Metrics, PeerId } from '@libp2p/interface';
|
|
5
5
|
import type { AddressManager } from '@libp2p/interface-internal';
|
|
6
6
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils';
|
package/dist/src/reprovider.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AdaptiveTimeout, Queue } from '@libp2p/utils';
|
|
2
2
|
import drain from 'it-drain';
|
|
3
3
|
import { TypedEventEmitter, setMaxListeners } from 'main-event';
|
|
4
|
-
import { PROVIDERS_VALIDITY, REPROVIDE_CONCURRENCY, REPROVIDE_INTERVAL, REPROVIDE_MAX_QUEUE_SIZE, REPROVIDE_THRESHOLD, REPROVIDE_TIMEOUT } from
|
|
5
|
-
import { parseProviderKey, readProviderTime, timeOperationMethod } from
|
|
4
|
+
import { PROVIDERS_VALIDITY, REPROVIDE_CONCURRENCY, REPROVIDE_INTERVAL, REPROVIDE_MAX_QUEUE_SIZE, REPROVIDE_THRESHOLD, REPROVIDE_TIMEOUT } from "./constants.js";
|
|
5
|
+
import { parseProviderKey, readProviderTime, timeOperationMethod } from "./utils.js";
|
|
6
6
|
export class Reprovider extends TypedEventEmitter {
|
|
7
7
|
log;
|
|
8
8
|
reprovideQueue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RoutingTable } from './index.
|
|
1
|
+
import type { RoutingTable } from './index.ts';
|
|
2
2
|
import type { ComponentLogger, Metrics, PeerId, PeerStore, Startable } from '@libp2p/interface';
|
|
3
3
|
export declare const PEER_SET_SIZE = 20;
|
|
4
4
|
export declare const REFRESH_INTERVAL = 5000;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'main-event';
|
|
2
|
-
import { KBucket } from './k-bucket.
|
|
3
|
-
import type { GetClosestPeersOptions, Peer } from './k-bucket.
|
|
2
|
+
import { KBucket } from './k-bucket.ts';
|
|
3
|
+
import type { GetClosestPeersOptions, Peer } from './k-bucket.ts';
|
|
4
4
|
import type { Network } from '../network.js';
|
|
5
5
|
import type { AbortOptions, ComponentLogger, Metrics, PeerId, PeerStore, Startable } from '@libp2p/interface';
|
|
6
6
|
import type { Ping } from '@libp2p/ping';
|
|
@@ -4,8 +4,8 @@ import { anySignal } from 'any-signal';
|
|
|
4
4
|
import parallel from 'it-parallel';
|
|
5
5
|
import { TypedEventEmitter, setMaxListeners } from 'main-event';
|
|
6
6
|
import * as utils from '../utils.js';
|
|
7
|
-
import { ClosestPeers } from
|
|
8
|
-
import { KBucket, isLeafBucket } from
|
|
7
|
+
import { ClosestPeers } from "./closest-peers.js";
|
|
8
|
+
import { KBucket, isLeafBucket } from "./k-bucket.js";
|
|
9
9
|
export const KBUCKET_SIZE = 20;
|
|
10
10
|
export const PREFIX_LENGTH = 6;
|
|
11
11
|
export const PING_NEW_CONTACT_TIMEOUT = 2000;
|
|
@@ -5,7 +5,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
|
5
5
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor';
|
|
6
6
|
import { PeerDistanceList } from '../peer-distance-list.js';
|
|
7
7
|
import { convertPeerId } from '../utils.js';
|
|
8
|
-
import { KBUCKET_SIZE, LAST_PING_THRESHOLD, PING_OLD_CONTACT_COUNT, PREFIX_LENGTH } from
|
|
8
|
+
import { KBUCKET_SIZE, LAST_PING_THRESHOLD, PING_OLD_CONTACT_COUNT, PREFIX_LENGTH } from "./index.js";
|
|
9
9
|
export function isLeafBucket(obj) {
|
|
10
10
|
return Array.isArray(obj?.peers);
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RoutingTable } from './index.
|
|
1
|
+
import type { RoutingTable } from './index.ts';
|
|
2
2
|
import type { PeerRouting } from '../peer-routing/index.js';
|
|
3
3
|
import type { AbortOptions, ComponentLogger, PeerId } from '@libp2p/interface';
|
|
4
4
|
export interface RoutingTableRefreshComponents {
|
|
@@ -7,7 +7,7 @@ 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
9
|
import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constants.js';
|
|
10
|
-
import GENERATED_PREFIXES from
|
|
10
|
+
import GENERATED_PREFIXES from "./generated-prefix-list.js";
|
|
11
11
|
/**
|
|
12
12
|
* Cannot generate random KadIds longer than this + 1
|
|
13
13
|
*/
|
package/dist/src/rpc/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Message } from '../message/dht.js';
|
|
|
2
2
|
import type { PeerInfoMapper, Validators } from '../index.js';
|
|
3
3
|
import type { PeerRouting } from '../peer-routing/index.js';
|
|
4
4
|
import type { Providers } from '../providers.js';
|
|
5
|
-
import type { FindNodeHandlerComponents } from './handlers/find-node.
|
|
6
|
-
import type { GetProvidersHandlerComponents } from './handlers/get-providers.
|
|
7
|
-
import type { GetValueHandlerComponents } from './handlers/get-value.
|
|
8
|
-
import type { PutValueHandlerComponents } from './handlers/put-value.
|
|
5
|
+
import type { FindNodeHandlerComponents } from './handlers/find-node.ts';
|
|
6
|
+
import type { GetProvidersHandlerComponents } from './handlers/get-providers.ts';
|
|
7
|
+
import type { GetValueHandlerComponents } from './handlers/get-value.ts';
|
|
8
|
+
import type { PutValueHandlerComponents } from './handlers/put-value.ts';
|
|
9
9
|
import type { RoutingTable } from '../routing-table/index.js';
|
|
10
10
|
import type { Metrics, PeerId, Connection, Stream } from '@libp2p/interface';
|
|
11
11
|
export interface DHTMessageHandler {
|
package/dist/src/rpc/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TimeoutError } from '@libp2p/interface';
|
|
2
2
|
import { pbStream } from '@libp2p/utils';
|
|
3
3
|
import { Message, MessageType } from '../message/dht.js';
|
|
4
|
-
import { AddProviderHandler } from
|
|
5
|
-
import { FindNodeHandler } from
|
|
6
|
-
import { GetProvidersHandler } from
|
|
7
|
-
import { GetValueHandler } from
|
|
8
|
-
import { PingHandler } from
|
|
9
|
-
import { PutValueHandler } from
|
|
4
|
+
import { AddProviderHandler } from "./handlers/add-provider.js";
|
|
5
|
+
import { FindNodeHandler } from "./handlers/find-node.js";
|
|
6
|
+
import { GetProvidersHandler } from "./handlers/get-providers.js";
|
|
7
|
+
import { GetValueHandler } from "./handlers/get-value.js";
|
|
8
|
+
import { PingHandler } from "./handlers/ping.js";
|
|
9
|
+
import { PutValueHandler } from "./handlers/put-value.js";
|
|
10
10
|
export class RPC {
|
|
11
11
|
handlers;
|
|
12
12
|
log;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'main-event';
|
|
2
|
-
import type { KadDHTComponents } from './index.
|
|
2
|
+
import type { KadDHTComponents } from './index.ts';
|
|
3
3
|
import type { PeerId, Startable } from '@libp2p/interface';
|
|
4
4
|
export interface TopologyListenerInit {
|
|
5
5
|
protocol: string;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Key } from 'interface-datastore/key';
|
|
2
2
|
import { CID } from 'multiformats/cid';
|
|
3
|
-
import type { Operation, OperationMetrics } from './kad-dht.
|
|
3
|
+
import type { Operation, OperationMetrics } from './kad-dht.ts';
|
|
4
4
|
import type { AbortOptions, PeerId, PeerInfo } from '@libp2p/interface';
|
|
5
5
|
export declare function removePrivateAddressesMapper(peer: PeerInfo): PeerInfo;
|
|
6
6
|
export declare function removePublicAddressesMapper(peer: PeerInfo): PeerInfo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/kad-dht",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.2-8f7e9264e",
|
|
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",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
31
|
"types": "./dist/src/index.d.ts",
|
|
32
|
-
"import": "./dist/src/index.js"
|
|
32
|
+
"import": "./dist/src/index.js",
|
|
33
|
+
"module-sync": "./dist/src/index.js"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
@@ -47,14 +48,14 @@
|
|
|
47
48
|
"doc-check": "aegir doc-check"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@libp2p/crypto": "
|
|
51
|
-
"@libp2p/interface": "
|
|
52
|
-
"@libp2p/interface-internal": "
|
|
53
|
-
"@libp2p/peer-collections": "
|
|
54
|
-
"@libp2p/peer-id": "
|
|
55
|
-
"@libp2p/ping": "
|
|
56
|
-
"@libp2p/record": "
|
|
57
|
-
"@libp2p/utils": "
|
|
51
|
+
"@libp2p/crypto": "5.1.17-8f7e9264e",
|
|
52
|
+
"@libp2p/interface": "3.2.2-8f7e9264e",
|
|
53
|
+
"@libp2p/interface-internal": "3.1.2-8f7e9264e",
|
|
54
|
+
"@libp2p/peer-collections": "7.0.17-8f7e9264e",
|
|
55
|
+
"@libp2p/peer-id": "6.0.8-8f7e9264e",
|
|
56
|
+
"@libp2p/ping": "3.1.2-8f7e9264e",
|
|
57
|
+
"@libp2p/record": "4.0.12-8f7e9264e",
|
|
58
|
+
"@libp2p/utils": "7.0.17-8f7e9264e",
|
|
58
59
|
"@multiformats/multiaddr": "^13.0.1",
|
|
59
60
|
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
60
61
|
"any-signal": "^4.1.1",
|
|
@@ -80,11 +81,11 @@
|
|
|
80
81
|
"uint8arrays": "^5.1.0"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@libp2p/logger": "
|
|
84
|
-
"@libp2p/peer-store": "
|
|
84
|
+
"@libp2p/logger": "6.2.6-8f7e9264e",
|
|
85
|
+
"@libp2p/peer-store": "12.0.17-8f7e9264e",
|
|
85
86
|
"@types/lodash.random": "^3.2.9",
|
|
86
87
|
"@types/lodash.range": "^3.2.9",
|
|
87
|
-
"@types/sinon": "^
|
|
88
|
+
"@types/sinon": "^21.0.1",
|
|
88
89
|
"@types/which": "^3.0.4",
|
|
89
90
|
"aegir": "^47.0.22",
|
|
90
91
|
"benchmark": "^2.1.4",
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
"it-length-prefixed": "^10.0.1",
|
|
98
99
|
"lodash.random": "^3.2.0",
|
|
99
100
|
"lodash.range": "^3.2.0",
|
|
100
|
-
"p-retry": "^
|
|
101
|
+
"p-retry": "^8.0.0",
|
|
101
102
|
"protons": "^8.1.1",
|
|
102
103
|
"sinon": "^21.0.0",
|
|
103
104
|
"sinon-ts": "^2.0.0",
|
package/src/index.ts
CHANGED
|
@@ -132,9 +132,9 @@
|
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
|
|
135
|
-
import { KadDHT as KadDHTClass } from './kad-dht.
|
|
136
|
-
import { MessageType } from './message/dht.
|
|
137
|
-
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from './utils.
|
|
135
|
+
import { KadDHT as KadDHTClass } from './kad-dht.ts'
|
|
136
|
+
import { MessageType } from './message/dht.ts'
|
|
137
|
+
import { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper } from './utils.ts'
|
|
138
138
|
import type { Libp2pEvents, ComponentLogger, Metrics, PeerId, PeerInfo, PeerStore, RoutingOptions, PrivateKey, AbortOptions } from '@libp2p/interface'
|
|
139
139
|
import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal'
|
|
140
140
|
import type { Ping } from '@libp2p/ping'
|
package/src/kad-dht.ts
CHANGED
|
@@ -4,26 +4,26 @@ import { Circuit } from '@multiformats/multiaddr-matcher'
|
|
|
4
4
|
import drain from 'it-drain'
|
|
5
5
|
import { setMaxListeners, TypedEventEmitter } from 'main-event'
|
|
6
6
|
import pDefer from 'p-defer'
|
|
7
|
-
import { ALPHA, ON_PEER_CONNECT_TIMEOUT, PROTOCOL } from './constants.
|
|
8
|
-
import { ContentFetching } from './content-fetching/index.
|
|
9
|
-
import { ContentRouting as KADDHTContentRouting } from './content-routing/index.
|
|
10
|
-
import { Network } from './network.
|
|
11
|
-
import { PeerRouting as KADDHTPeerRouting } from './peer-routing/index.
|
|
12
|
-
import { Providers } from './providers.
|
|
13
|
-
import { QueryManager } from './query/manager.
|
|
14
|
-
import { QuerySelf } from './query-self.
|
|
15
|
-
import { selectors as recordSelectors } from './record/selectors.
|
|
16
|
-
import { validators as recordValidators } from './record/validators.
|
|
17
|
-
import { Reprovider } from './reprovider.
|
|
18
|
-
import { KBUCKET_SIZE, RoutingTable } from './routing-table/index.
|
|
19
|
-
import { RoutingTableRefresh } from './routing-table/refresh.
|
|
20
|
-
import { RPC } from './rpc/index.
|
|
21
|
-
import { TopologyListener } from './topology-listener.
|
|
7
|
+
import { ALPHA, ON_PEER_CONNECT_TIMEOUT, PROTOCOL } from './constants.ts'
|
|
8
|
+
import { ContentFetching } from './content-fetching/index.ts'
|
|
9
|
+
import { ContentRouting as KADDHTContentRouting } from './content-routing/index.ts'
|
|
10
|
+
import { Network } from './network.ts'
|
|
11
|
+
import { PeerRouting as KADDHTPeerRouting } from './peer-routing/index.ts'
|
|
12
|
+
import { Providers } from './providers.ts'
|
|
13
|
+
import { QueryManager } from './query/manager.ts'
|
|
14
|
+
import { QuerySelf } from './query-self.ts'
|
|
15
|
+
import { selectors as recordSelectors } from './record/selectors.ts'
|
|
16
|
+
import { validators as recordValidators } from './record/validators.ts'
|
|
17
|
+
import { Reprovider } from './reprovider.ts'
|
|
18
|
+
import { KBUCKET_SIZE, RoutingTable } from './routing-table/index.ts'
|
|
19
|
+
import { RoutingTableRefresh } from './routing-table/refresh.ts'
|
|
20
|
+
import { RPC } from './rpc/index.ts'
|
|
21
|
+
import { TopologyListener } from './topology-listener.ts'
|
|
22
22
|
import {
|
|
23
23
|
removePrivateAddressesMapper,
|
|
24
24
|
timeOperationGenerator
|
|
25
|
-
} from './utils.
|
|
26
|
-
import type { KadDHTComponents, KadDHTInit, Validators, Selectors, KadDHT as KadDHTInterface, QueryEvent, PeerInfoMapper, SetModeOptions } from './index.
|
|
25
|
+
} from './utils.ts'
|
|
26
|
+
import type { KadDHTComponents, KadDHTInit, Validators, Selectors, KadDHT as KadDHTInterface, QueryEvent, PeerInfoMapper, SetModeOptions } from './index.ts'
|
|
27
27
|
import type { ContentRouting, CounterGroup, Logger, MetricGroup, PeerDiscovery, PeerDiscoveryEvents, PeerId, PeerInfo, PeerRouting, Provider, RoutingOptions, Startable } from '@libp2p/interface'
|
|
28
28
|
import type { AbortOptions } from 'it-pushable'
|
|
29
29
|
import type { CID } from 'multiformats/cid'
|
package/src/message/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { peerIdFromMultihash } from '@libp2p/peer-id'
|
|
2
2
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
3
3
|
import * as Digest from 'multiformats/hashes/digest'
|
|
4
|
-
import type { PeerInfo as PBPeerInfo, ConnectionType } from './dht.
|
|
4
|
+
import type { PeerInfo as PBPeerInfo, ConnectionType } from './dht.ts'
|
|
5
5
|
import type { PeerInfo } from '@libp2p/interface'
|
|
6
6
|
|
|
7
7
|
export function toPbPeerInfo (peer: PeerInfo, connection?: ConnectionType): PBPeerInfo {
|
package/src/network.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { InvalidParametersError } from '@libp2p/interface'
|
|
|
2
2
|
import { Libp2pRecord } from '@libp2p/record'
|
|
3
3
|
import { AdaptiveTimeout, pbStream } from '@libp2p/utils'
|
|
4
4
|
import { TypedEventEmitter } from 'main-event'
|
|
5
|
-
import { Message } from './message/dht.
|
|
6
|
-
import { fromPbPeerInfo } from './message/utils.
|
|
5
|
+
import { Message } from './message/dht.ts'
|
|
6
|
+
import { fromPbPeerInfo } from './message/utils.ts'
|
|
7
7
|
import {
|
|
8
8
|
sendQueryEvent,
|
|
9
9
|
peerResponseEvent,
|
|
10
10
|
queryErrorEvent,
|
|
11
11
|
dialPeerEvent
|
|
12
|
-
} from './query/events.
|
|
13
|
-
import type { DisjointPath, KadDHTComponents, QueryEvent } from './index.
|
|
12
|
+
} from './query/events.ts'
|
|
13
|
+
import type { DisjointPath, KadDHTComponents, QueryEvent } from './index.ts'
|
|
14
14
|
import type { AbortOptions, Logger, Stream, PeerId, PeerInfo, Startable, RoutingOptions, CounterGroup } from '@libp2p/interface'
|
|
15
15
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils'
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
2
2
|
import { xorCompare as uint8ArrayXorCompare } from 'uint8arrays/xor-compare'
|
|
3
|
-
import { convertPeerId } from './utils.
|
|
4
|
-
import type { DisjointPath } from './index.
|
|
3
|
+
import { convertPeerId } from './utils.ts'
|
|
4
|
+
import type { DisjointPath } from './index.ts'
|
|
5
5
|
import type { AbortOptions, PeerId, PeerInfo } from '@libp2p/interface'
|
|
6
6
|
|
|
7
7
|
interface PeerDistance {
|
package/src/providers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
2
2
|
import * as varint from 'uint8-varint'
|
|
3
|
-
import { parseProviderKey, readProviderTime, toProviderKey } from './utils.
|
|
3
|
+
import { parseProviderKey, readProviderTime, toProviderKey } from './utils.ts'
|
|
4
4
|
import type { AbortOptions, ComponentLogger, Logger, Metrics, PeerId } from '@libp2p/interface'
|
|
5
5
|
import type { Datastore } from 'interface-datastore'
|
|
6
6
|
import type { CID } from 'multiformats'
|
package/src/query/manager.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
ALPHA, K, DEFAULT_QUERY_TIMEOUT
|
|
10
10
|
} from '../constants.js'
|
|
11
11
|
import { convertBuffer } from '../utils.js'
|
|
12
|
-
import { queryPath } from './query-path.
|
|
13
|
-
import type { QueryFunc } from './types.
|
|
12
|
+
import { queryPath } from './query-path.ts'
|
|
13
|
+
import type { QueryFunc } from './types.ts'
|
|
14
14
|
import type { QueryEvent } from '../index.js'
|
|
15
15
|
import type { RoutingTable } from '../routing-table/index.js'
|
|
16
16
|
import type { ComponentLogger, Metrics, PeerId, RoutingOptions, Startable } from '@libp2p/interface'
|
package/src/query/query-path.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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
6
|
import { convertPeerId, convertBuffer } from '../utils.js'
|
|
7
|
-
import { pathEndedEvent, queryErrorEvent } from './events.
|
|
7
|
+
import { pathEndedEvent, queryErrorEvent } from './events.ts'
|
|
8
8
|
import type { QueryEvent } from '../index.js'
|
|
9
9
|
import type { QueryFunc } from '../query/types.js'
|
|
10
10
|
import type { Logger, PeerId, RoutingOptions, AbortOptions, PeerInfo } from '@libp2p/interface'
|
package/src/query-self.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { pipe } from 'it-pipe'
|
|
|
4
4
|
import take from 'it-take'
|
|
5
5
|
import { setMaxListeners } from 'main-event'
|
|
6
6
|
import pDefer from 'p-defer'
|
|
7
|
-
import { QUERY_SELF_INTERVAL, QUERY_SELF_TIMEOUT, K, QUERY_SELF_INITIAL_INTERVAL } from './constants.
|
|
8
|
-
import { timeOperationMethod } from './utils.
|
|
9
|
-
import type { OperationMetrics } from './kad-dht.
|
|
10
|
-
import type { PeerRouting } from './peer-routing/index.
|
|
7
|
+
import { QUERY_SELF_INTERVAL, QUERY_SELF_TIMEOUT, K, QUERY_SELF_INITIAL_INTERVAL } from './constants.ts'
|
|
8
|
+
import { timeOperationMethod } from './utils.ts'
|
|
9
|
+
import type { OperationMetrics } from './kad-dht.ts'
|
|
10
|
+
import type { PeerRouting } from './peer-routing/index.ts'
|
|
11
11
|
import type { ComponentLogger, Logger, Metrics, PeerId, Startable } from '@libp2p/interface'
|
|
12
12
|
import type { DeferredPromise } from 'p-defer'
|
|
13
13
|
|
package/src/reprovider.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AdaptiveTimeout, Queue } from '@libp2p/utils'
|
|
2
2
|
import drain from 'it-drain'
|
|
3
3
|
import { TypedEventEmitter, setMaxListeners } from 'main-event'
|
|
4
|
-
import { PROVIDERS_VALIDITY, REPROVIDE_CONCURRENCY, REPROVIDE_INTERVAL, REPROVIDE_MAX_QUEUE_SIZE, REPROVIDE_THRESHOLD, REPROVIDE_TIMEOUT } from './constants.
|
|
5
|
-
import { parseProviderKey, readProviderTime, timeOperationMethod } from './utils.
|
|
6
|
-
import type { ContentRouting } from './content-routing/index.
|
|
7
|
-
import type { OperationMetrics } from './kad-dht.
|
|
4
|
+
import { PROVIDERS_VALIDITY, REPROVIDE_CONCURRENCY, REPROVIDE_INTERVAL, REPROVIDE_MAX_QUEUE_SIZE, REPROVIDE_THRESHOLD, REPROVIDE_TIMEOUT } from './constants.ts'
|
|
5
|
+
import { parseProviderKey, readProviderTime, timeOperationMethod } from './utils.ts'
|
|
6
|
+
import type { ContentRouting } from './content-routing/index.ts'
|
|
7
|
+
import type { OperationMetrics } from './kad-dht.ts'
|
|
8
8
|
import type { AbortOptions, ComponentLogger, Logger, Metrics, PeerId } from '@libp2p/interface'
|
|
9
9
|
import type { AddressManager } from '@libp2p/interface-internal'
|
|
10
10
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils'
|
|
@@ -2,7 +2,7 @@ import { PeerSet } from '@libp2p/peer-collections'
|
|
|
2
2
|
import { KEEP_ALIVE_TAG } from '../constants.js'
|
|
3
3
|
import { PeerDistanceList } from '../peer-distance-list.js'
|
|
4
4
|
import { convertPeerId } from '../utils.js'
|
|
5
|
-
import type { RoutingTable } from './index.
|
|
5
|
+
import type { RoutingTable } from './index.ts'
|
|
6
6
|
import type { ComponentLogger, Logger, Metrics, PeerId, PeerStore, Startable } from '@libp2p/interface'
|
|
7
7
|
|
|
8
8
|
export const PEER_SET_SIZE = 20
|
|
@@ -4,9 +4,9 @@ import { anySignal } from 'any-signal'
|
|
|
4
4
|
import parallel from 'it-parallel'
|
|
5
5
|
import { TypedEventEmitter, setMaxListeners } from 'main-event'
|
|
6
6
|
import * as utils from '../utils.js'
|
|
7
|
-
import { ClosestPeers } from './closest-peers.
|
|
8
|
-
import { KBucket, isLeafBucket } from './k-bucket.
|
|
9
|
-
import type { Bucket, GetClosestPeersOptions, LeafBucket, Peer } from './k-bucket.
|
|
7
|
+
import { ClosestPeers } from './closest-peers.ts'
|
|
8
|
+
import { KBucket, isLeafBucket } from './k-bucket.ts'
|
|
9
|
+
import type { Bucket, GetClosestPeersOptions, LeafBucket, Peer } from './k-bucket.ts'
|
|
10
10
|
import type { Network } from '../network.js'
|
|
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'
|
|
@@ -5,7 +5,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
|
5
5
|
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
6
6
|
import { PeerDistanceList } from '../peer-distance-list.js'
|
|
7
7
|
import { convertPeerId } from '../utils.js'
|
|
8
|
-
import { KBUCKET_SIZE, LAST_PING_THRESHOLD, PING_OLD_CONTACT_COUNT, PREFIX_LENGTH } from './index.
|
|
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
|
|
|
11
11
|
export interface PingFunction {
|
|
@@ -7,8 +7,8 @@ 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
9
|
import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constants.js'
|
|
10
|
-
import GENERATED_PREFIXES from './generated-prefix-list.
|
|
11
|
-
import type { RoutingTable } from './index.
|
|
10
|
+
import GENERATED_PREFIXES from './generated-prefix-list.ts'
|
|
11
|
+
import type { RoutingTable } from './index.ts'
|
|
12
12
|
import type { PeerRouting } from '../peer-routing/index.js'
|
|
13
13
|
import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface'
|
|
14
14
|
|