@libp2p/kad-dht 9.1.1 → 9.1.2
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 +18 -18
- package/dist/src/content-fetching/index.d.ts +3 -3
- package/dist/src/content-fetching/index.d.ts.map +1 -1
- package/dist/src/content-fetching/index.js +14 -6
- package/dist/src/content-fetching/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +5 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +12 -5
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/dual-kad-dht.d.ts +7 -7
- package/dist/src/dual-kad-dht.d.ts.map +1 -1
- package/dist/src/dual-kad-dht.js +9 -10
- package/dist/src/dual-kad-dht.js.map +1 -1
- package/dist/src/index.d.ts +9 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/kad-dht.d.ts +8 -8
- package/dist/src/kad-dht.d.ts.map +1 -1
- package/dist/src/kad-dht.js +35 -17
- package/dist/src/kad-dht.js.map +1 -1
- package/dist/src/message/index.d.ts.map +1 -1
- package/dist/src/message/index.js +7 -1
- package/dist/src/message/index.js.map +1 -1
- package/dist/src/network.d.ts +4 -4
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +9 -5
- package/dist/src/network.js.map +1 -1
- package/dist/src/peer-list/index.js +1 -0
- package/dist/src/peer-list/index.js.map +1 -1
- package/dist/src/peer-list/peer-distance-list.js +10 -1
- package/dist/src/peer-list/peer-distance-list.js.map +1 -1
- package/dist/src/peer-routing/index.d.ts +6 -6
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.js +12 -6
- package/dist/src/peer-routing/index.js.map +1 -1
- package/dist/src/providers.d.ts +2 -2
- package/dist/src/providers.d.ts.map +1 -1
- package/dist/src/providers.js +12 -5
- package/dist/src/providers.js.map +1 -1
- package/dist/src/query/events.d.ts +1 -1
- package/dist/src/query/events.d.ts.map +1 -1
- package/dist/src/query/manager.d.ts +3 -3
- package/dist/src/query/manager.d.ts.map +1 -1
- package/dist/src/query/manager.js +15 -6
- package/dist/src/query/manager.js.map +1 -1
- package/dist/src/query/query-path.d.ts +3 -3
- package/dist/src/query/query-path.d.ts.map +1 -1
- package/dist/src/query/query-path.js +4 -4
- package/dist/src/query/query-path.js.map +1 -1
- package/dist/src/query/types.d.ts +1 -1
- package/dist/src/query/types.d.ts.map +1 -1
- package/dist/src/query-self.d.ts +2 -2
- package/dist/src/query-self.d.ts.map +1 -1
- package/dist/src/query-self.js +18 -5
- package/dist/src/query-self.js.map +1 -1
- package/dist/src/routing-table/index.d.ts +3 -3
- package/dist/src/routing-table/index.d.ts.map +1 -1
- package/dist/src/routing-table/index.js +16 -3
- package/dist/src/routing-table/index.js.map +1 -1
- package/dist/src/routing-table/refresh.d.ts.map +1 -1
- package/dist/src/routing-table/refresh.js +11 -4
- package/dist/src/routing-table/refresh.js.map +1 -1
- package/dist/src/rpc/handlers/add-provider.d.ts +2 -2
- package/dist/src/rpc/handlers/add-provider.d.ts.map +1 -1
- package/dist/src/rpc/handlers/add-provider.js +2 -1
- package/dist/src/rpc/handlers/add-provider.js.map +1 -1
- package/dist/src/rpc/handlers/find-node.d.ts +2 -2
- package/dist/src/rpc/handlers/find-node.d.ts.map +1 -1
- package/dist/src/rpc/handlers/find-node.js +6 -3
- package/dist/src/rpc/handlers/find-node.js.map +1 -1
- package/dist/src/rpc/handlers/get-providers.d.ts +2 -2
- package/dist/src/rpc/handlers/get-providers.d.ts.map +1 -1
- package/dist/src/rpc/handlers/get-providers.js +6 -2
- package/dist/src/rpc/handlers/get-providers.js.map +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
- package/dist/src/rpc/handlers/get-value.js +5 -3
- package/dist/src/rpc/handlers/get-value.js.map +1 -1
- package/dist/src/rpc/handlers/put-value.d.ts +1 -1
- package/dist/src/rpc/handlers/put-value.d.ts.map +1 -1
- package/dist/src/rpc/handlers/put-value.js +5 -2
- package/dist/src/rpc/handlers/put-value.js.map +1 -1
- package/dist/src/rpc/index.d.ts +8 -8
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +6 -3
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/src/topology-listener.d.ts +2 -2
- package/dist/src/topology-listener.d.ts.map +1 -1
- package/dist/src/topology-listener.js +6 -1
- package/dist/src/topology-listener.js.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +6 -6
- package/dist/src/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/content-fetching/index.ts +14 -14
- package/src/content-routing/index.ts +13 -13
- package/src/dual-kad-dht.ts +9 -13
- package/src/index.ts +13 -13
- package/src/kad-dht.ts +16 -20
- package/src/message/index.ts +1 -1
- package/src/network.ts +9 -9
- package/src/peer-list/peer-distance-list.ts +1 -1
- package/src/peer-routing/index.ts +13 -13
- package/src/providers.ts +7 -7
- package/src/query/events.ts +1 -1
- package/src/query/manager.ts +10 -10
- package/src/query/query-path.ts +8 -8
- package/src/query/types.ts +1 -1
- package/src/query-self.ts +7 -7
- package/src/routing-table/index.ts +6 -6
- package/src/routing-table/refresh.ts +5 -5
- package/src/rpc/handlers/add-provider.ts +3 -3
- package/src/rpc/handlers/find-node.ts +6 -6
- package/src/rpc/handlers/get-providers.ts +4 -4
- package/src/rpc/handlers/get-value.ts +4 -4
- package/src/rpc/handlers/put-value.ts +3 -3
- package/src/rpc/index.ts +11 -11
- package/src/topology-listener.ts +4 -4
- package/src/utils.ts +8 -8
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
2
|
-
import GENERATED_PREFIXES from './generated-prefix-list.js'
|
|
3
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
|
4
1
|
import { randomBytes } from '@libp2p/crypto'
|
|
5
|
-
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
6
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
+
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
7
4
|
import length from 'it-length'
|
|
5
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
6
|
+
import { xor as uint8ArrayXor } from 'uint8arrays/xor'
|
|
8
7
|
import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constants.js'
|
|
8
|
+
import GENERATED_PREFIXES from './generated-prefix-list.js'
|
|
9
9
|
import type { RoutingTable } from './index.js'
|
|
10
|
-
import type { Logger } from '@libp2p/logger'
|
|
11
10
|
import type { PeerRouting } from '../peer-routing/index.js'
|
|
12
11
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
12
|
+
import type { Logger } from '@libp2p/logger'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Cannot generate random KadIds longer than this + 1
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid'
|
|
2
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
+
import { CID } from 'multiformats/cid'
|
|
4
|
+
import type { Message } from '../../message/index.js'
|
|
4
5
|
import type { Providers } from '../../providers'
|
|
5
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
6
6
|
import type { DHTMessageHandler } from '../index.js'
|
|
7
|
-
import type {
|
|
7
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
8
8
|
|
|
9
9
|
const log = logger('libp2p:kad-dht:rpc:handlers:add-provider')
|
|
10
10
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Message } from '../../message/index.js'
|
|
2
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
+
import { protocols } from '@multiformats/multiaddr'
|
|
3
|
+
import { equals as uint8ArrayEquals } from 'uint8arrays'
|
|
4
|
+
import { Message } from '../../message/index.js'
|
|
3
5
|
import {
|
|
4
6
|
removePrivateAddresses,
|
|
5
7
|
removePublicAddresses
|
|
6
8
|
} from '../../utils.js'
|
|
7
|
-
import { equals as uint8ArrayEquals } from 'uint8arrays'
|
|
8
|
-
import { protocols } from '@multiformats/multiaddr'
|
|
9
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
10
|
-
import type { DHTMessageHandler } from '../index.js'
|
|
11
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
12
|
-
import type {
|
|
10
|
+
import type { DHTMessageHandler } from '../index.js'
|
|
13
11
|
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
12
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
13
|
+
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
14
14
|
|
|
15
15
|
const log = logger('libp2p:kad-dht:rpc:handlers:find-node')
|
|
16
16
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid'
|
|
2
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
2
|
+
import { logger } from '@libp2p/logger'
|
|
3
|
+
import { CID } from 'multiformats/cid'
|
|
3
4
|
import { Message } from '../../message/index.js'
|
|
4
5
|
import {
|
|
5
6
|
removePrivateAddresses,
|
|
6
7
|
removePublicAddresses
|
|
7
8
|
} from '../../utils.js'
|
|
8
|
-
import { logger } from '@libp2p/logger'
|
|
9
|
-
import type { DHTMessageHandler } from '../index.js'
|
|
10
|
-
import type { Providers } from '../../providers.js'
|
|
11
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
10
|
+
import type { Providers } from '../../providers.js'
|
|
11
|
+
import type { DHTMessageHandler } from '../index.js'
|
|
12
12
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
13
13
|
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
14
14
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Libp2pRecord } from '@libp2p/record'
|
|
2
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
-
import {
|
|
2
|
+
import { logger } from '@libp2p/logger'
|
|
3
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
4
4
|
import {
|
|
5
5
|
MAX_RECORD_AGE
|
|
6
6
|
} from '../../constants.js'
|
|
7
|
+
import { Message, MESSAGE_TYPE } from '../../message/index.js'
|
|
7
8
|
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.js'
|
|
8
|
-
import {
|
|
9
|
+
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
9
10
|
import type { DHTMessageHandler } from '../index.js'
|
|
10
11
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
|
-
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
12
12
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
13
13
|
import type { Datastore } from 'interface-datastore'
|
|
14
14
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { bufferToRecordKey } from '../../utils.js'
|
|
2
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
2
|
+
import { type Logger, logger } from '@libp2p/logger'
|
|
3
3
|
import { verifyRecord } from '@libp2p/record/validators'
|
|
4
|
-
import {
|
|
4
|
+
import { bufferToRecordKey } from '../../utils.js'
|
|
5
|
+
import type { Message } from '../../message/index.js'
|
|
5
6
|
import type { DHTMessageHandler } from '../index.js'
|
|
6
7
|
import type { Validators } from '@libp2p/interface-dht'
|
|
7
8
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
8
|
-
import type { Message } from '../../message/index.js'
|
|
9
9
|
import type { Datastore } from 'interface-datastore'
|
|
10
10
|
|
|
11
11
|
export interface PutValueHandlerInit {
|
package/src/rpc/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Logger, logger } from '@libp2p/logger'
|
|
2
2
|
import * as lp from 'it-length-prefixed'
|
|
3
|
-
import {
|
|
4
|
-
import type { RoutingTable } from '../routing-table'
|
|
5
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
3
|
+
import { pipe } from 'it-pipe'
|
|
6
4
|
import { Message, MESSAGE_TYPE } from '../message/index.js'
|
|
7
5
|
import { AddProviderHandler } from './handlers/add-provider.js'
|
|
8
|
-
import { FindNodeHandler, FindNodeHandlerComponents } from './handlers/find-node.js'
|
|
9
|
-
import { GetProvidersHandler, GetProvidersHandlerComponents } from './handlers/get-providers.js'
|
|
10
|
-
import { GetValueHandler, GetValueHandlerComponents } from './handlers/get-value.js'
|
|
6
|
+
import { FindNodeHandler, type FindNodeHandlerComponents } from './handlers/find-node.js'
|
|
7
|
+
import { GetProvidersHandler, type GetProvidersHandlerComponents } from './handlers/get-providers.js'
|
|
8
|
+
import { GetValueHandler, type GetValueHandlerComponents } from './handlers/get-value.js'
|
|
11
9
|
import { PingHandler } from './handlers/ping.js'
|
|
12
|
-
import { PutValueHandler, PutValueHandlerComponents } from './handlers/put-value.js'
|
|
13
|
-
import type { IncomingStreamData } from '@libp2p/interface-registrar'
|
|
14
|
-
import type { Providers } from '../providers'
|
|
10
|
+
import { PutValueHandler, type PutValueHandlerComponents } from './handlers/put-value.js'
|
|
15
11
|
import type { PeerRouting } from '../peer-routing'
|
|
12
|
+
import type { Providers } from '../providers'
|
|
13
|
+
import type { RoutingTable } from '../routing-table'
|
|
16
14
|
import type { Validators } from '@libp2p/interface-dht'
|
|
15
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
16
|
+
import type { IncomingStreamData } from '@libp2p/interface-registrar'
|
|
17
17
|
|
|
18
18
|
export interface DHTMessageHandler {
|
|
19
19
|
handle: (peerId: PeerId, msg: Message) => Promise<Message | undefined>
|
|
@@ -69,7 +69,7 @@ export class RPC {
|
|
|
69
69
|
return
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return handler.handle(peerId, msg)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
package/src/topology-listener.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createTopology } from '@libp2p/topology'
|
|
2
1
|
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
|
|
3
2
|
import { logger } from '@libp2p/logger'
|
|
4
|
-
import
|
|
5
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
6
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
3
|
+
import { createTopology } from '@libp2p/topology'
|
|
7
4
|
import type { KadDHTComponents } from '.'
|
|
5
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
6
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
7
|
+
import type { Logger } from '@libp2p/logger'
|
|
8
8
|
|
|
9
9
|
export interface TopologyListenerInit {
|
|
10
10
|
protocol: string
|
package/src/utils.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Key } from 'interface-datastore/key'
|
|
1
|
+
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
3
2
|
import { Libp2pRecord } from '@libp2p/record'
|
|
3
|
+
import { Key } from 'interface-datastore/key'
|
|
4
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
5
|
+
import isPrivateIp from 'private-ip'
|
|
6
|
+
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
4
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
5
8
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
6
|
-
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
7
|
-
import isPrivateIp from 'private-ip'
|
|
8
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
9
|
-
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
10
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
9
|
import { RECORD_KEY_PREFIX } from './constants.js'
|
|
10
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
|
+
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
12
12
|
|
|
13
13
|
// const IPNS_PREFIX = uint8ArrayFromString('/ipns/')
|
|
14
14
|
const PK_PREFIX = uint8ArrayFromString('/pk/')
|
|
@@ -92,7 +92,7 @@ export async function convertBuffer (buf: Uint8Array): Promise<Uint8Array> {
|
|
|
92
92
|
* Creates a DHT ID by hashing a Peer ID
|
|
93
93
|
*/
|
|
94
94
|
export async function convertPeerId (peerId: PeerId): Promise<Uint8Array> {
|
|
95
|
-
return
|
|
95
|
+
return convertBuffer(peerId.toBytes())
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|