@libp2p/kad-dht 9.3.6-ab0e3980 → 9.3.6-b36ec7f2
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/README.md +3 -1
- package/dist/index.min.js +19 -19
- package/dist/src/content-fetching/index.d.ts +2 -2
- package/dist/src/content-fetching/index.d.ts.map +1 -1
- package/dist/src/content-fetching/index.js +4 -4
- package/dist/src/content-fetching/index.js.map +1 -1
- package/dist/src/dual-kad-dht.d.ts +5 -5
- package/dist/src/dual-kad-dht.d.ts.map +1 -1
- package/dist/src/dual-kad-dht.js +5 -5
- package/dist/src/dual-kad-dht.js.map +1 -1
- package/dist/src/index.d.ts +9 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/kad-dht.d.ts +4 -4
- package/dist/src/kad-dht.d.ts.map +1 -1
- package/dist/src/kad-dht.js +3 -3
- package/dist/src/kad-dht.js.map +1 -1
- package/dist/src/message/index.d.ts +2 -2
- package/dist/src/message/index.d.ts.map +1 -1
- package/dist/src/message/index.js +1 -1
- package/dist/src/message/index.js.map +1 -1
- package/dist/src/network.d.ts +5 -5
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +4 -4
- package/dist/src/network.js.map +1 -1
- package/dist/src/peer-list/index.d.ts +1 -1
- package/dist/src/peer-list/peer-distance-list.d.ts +1 -1
- package/dist/src/peer-routing/index.d.ts +3 -3
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.js +3 -3
- 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/query/events.d.ts +3 -3
- package/dist/src/query/events.d.ts.map +1 -1
- package/dist/src/query/events.js +1 -1
- package/dist/src/query/events.js.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 +2 -2
- package/dist/src/query/manager.js.map +1 -1
- package/dist/src/query/query-path.d.ts +2 -2
- package/dist/src/query/query-path.d.ts.map +1 -1
- package/dist/src/query/query-path.js +1 -1
- package/dist/src/query/query-path.js.map +1 -1
- package/dist/src/query/types.d.ts +1 -1
- package/dist/src/query-self.d.ts +2 -2
- package/dist/src/query-self.d.ts.map +1 -1
- package/dist/src/record/index.d.ts +22 -0
- package/dist/src/record/index.d.ts.map +1 -0
- package/dist/src/record/index.js +53 -0
- package/dist/src/record/index.js.map +1 -0
- package/dist/src/record/record.d.ts +13 -0
- package/dist/src/record/record.d.ts.map +1 -0
- package/dist/src/record/record.js +67 -0
- package/dist/src/record/record.js.map +1 -0
- package/dist/src/record/selectors.d.ts +7 -0
- package/dist/src/record/selectors.d.ts.map +1 -0
- package/dist/src/record/selectors.js +38 -0
- package/dist/src/record/selectors.js.map +1 -0
- package/dist/src/record/utils.d.ts +11 -0
- package/dist/src/record/utils.d.ts.map +1 -0
- package/dist/src/record/utils.js +41 -0
- package/dist/src/record/utils.js.map +1 -0
- package/dist/src/record/validators.d.ts +10 -0
- package/dist/src/record/validators.d.ts.map +1 -0
- package/dist/src/record/validators.js +54 -0
- package/dist/src/record/validators.js.map +1 -0
- package/dist/src/routing-table/index.d.ts +6 -6
- package/dist/src/routing-table/index.d.ts.map +1 -1
- package/dist/src/routing-table/index.js +2 -2
- package/dist/src/routing-table/index.js.map +1 -1
- package/dist/src/routing-table/k-bucket.d.ts +2 -2
- package/dist/src/routing-table/k-bucket.d.ts.map +1 -1
- package/dist/src/routing-table/k-bucket.js +1 -1
- package/dist/src/routing-table/k-bucket.js.map +1 -1
- package/dist/src/routing-table/refresh.d.ts +1 -1
- package/dist/src/rpc/handlers/add-provider.d.ts +1 -1
- package/dist/src/rpc/handlers/add-provider.js +1 -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/get-providers.d.ts +3 -3
- package/dist/src/rpc/handlers/get-providers.js +1 -1
- package/dist/src/rpc/handlers/get-providers.js.map +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts +3 -3
- package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
- package/dist/src/rpc/handlers/get-value.js +2 -2
- package/dist/src/rpc/handlers/get-value.js.map +1 -1
- package/dist/src/rpc/handlers/ping.d.ts +1 -1
- package/dist/src/rpc/handlers/put-value.d.ts +1 -1
- package/dist/src/rpc/handlers/put-value.js +2 -2
- package/dist/src/rpc/handlers/put-value.js.map +1 -1
- package/dist/src/rpc/index.d.ts +2 -2
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/topology-listener.d.ts +3 -3
- package/dist/src/topology-listener.d.ts.map +1 -1
- package/dist/src/topology-listener.js +2 -4
- package/dist/src/topology-listener.js.map +1 -1
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/package.json +20 -33
- package/src/content-fetching/index.ts +5 -5
- package/src/content-routing/index.ts +1 -1
- package/src/dual-kad-dht.ts +7 -7
- package/src/index.ts +9 -10
- package/src/kad-dht.ts +6 -6
- package/src/message/index.ts +2 -2
- package/src/network.ts +9 -9
- package/src/peer-list/index.ts +1 -1
- package/src/peer-list/peer-distance-list.ts +1 -1
- package/src/peer-routing/index.ts +6 -6
- package/src/providers.ts +2 -2
- package/src/query/events.ts +4 -4
- package/src/query/manager.ts +5 -5
- package/src/query/query-path.ts +3 -3
- package/src/query/types.ts +1 -1
- package/src/query-self.ts +2 -2
- package/src/record/index.ts +70 -0
- package/src/record/record.proto +20 -0
- package/src/record/record.ts +87 -0
- package/src/record/selectors.ts +50 -0
- package/src/record/utils.ts +46 -0
- package/src/record/validators.ts +69 -0
- package/src/routing-table/index.ts +7 -7
- package/src/routing-table/k-bucket.ts +2 -2
- package/src/routing-table/refresh.ts +1 -1
- package/src/rpc/handlers/add-provider.ts +2 -2
- package/src/rpc/handlers/find-node.ts +3 -3
- package/src/rpc/handlers/get-providers.ts +4 -4
- package/src/rpc/handlers/get-value.ts +4 -4
- package/src/rpc/handlers/ping.ts +1 -1
- package/src/rpc/handlers/put-value.ts +3 -3
- package/src/rpc/index.ts +2 -2
- package/src/topology-listener.ts +4 -6
- package/src/utils.ts +3 -3
|
@@ -27,8 +27,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
27
27
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import { EventEmitter } from '@libp2p/
|
|
31
|
-
import type { PeerId } from '@libp2p/interface
|
|
30
|
+
import { EventEmitter } from '@libp2p/interface/events'
|
|
31
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
32
32
|
|
|
33
33
|
function arrayEquals (array1: Uint8Array, array2: Uint8Array): boolean {
|
|
34
34
|
if (array1 === array2) {
|
|
@@ -8,7 +8,7 @@ import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constant
|
|
|
8
8
|
import GENERATED_PREFIXES from './generated-prefix-list.js'
|
|
9
9
|
import type { RoutingTable } from './index.js'
|
|
10
10
|
import type { PeerRouting } from '../peer-routing/index.js'
|
|
11
|
-
import type { PeerId } from '@libp2p/interface
|
|
11
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
12
12
|
import type { Logger } from '@libp2p/logger'
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import { CID } from 'multiformats/cid'
|
|
4
4
|
import type { Message } from '../../message/index.js'
|
|
5
5
|
import type { Providers } from '../../providers'
|
|
6
6
|
import type { DHTMessageHandler } from '../index.js'
|
|
7
|
-
import type { PeerId } from '@libp2p/interface
|
|
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
|
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
} from '../../utils.js'
|
|
9
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
10
10
|
import type { DHTMessageHandler } from '../index.js'
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
11
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
12
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
13
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
14
14
|
|
|
15
15
|
const log = logger('libp2p:kad-dht:rpc:handlers:find-node')
|
|
16
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import { CID } from 'multiformats/cid'
|
|
4
4
|
import { Message } from '../../message/index.js'
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
10
10
|
import type { Providers } from '../../providers.js'
|
|
11
11
|
import type { DHTMessageHandler } from '../index.js'
|
|
12
|
-
import type { PeerId } from '@libp2p/interface
|
|
13
|
-
import type { PeerInfo } from '@libp2p/interface
|
|
14
|
-
import type { PeerStore } from '@libp2p/interface
|
|
12
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
13
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
14
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
15
15
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
16
16
|
|
|
17
17
|
const log = logger('libp2p:kad-dht:rpc:handlers:get-providers')
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
-
import { Libp2pRecord } from '@libp2p/record'
|
|
4
3
|
import {
|
|
5
4
|
MAX_RECORD_AGE
|
|
6
5
|
} from '../../constants.js'
|
|
7
6
|
import { Message, MESSAGE_TYPE } from '../../message/index.js'
|
|
7
|
+
import { Libp2pRecord } from '../../record/index.js'
|
|
8
8
|
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.js'
|
|
9
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
10
10
|
import type { DHTMessageHandler } from '../index.js'
|
|
11
|
-
import type { PeerId } from '@libp2p/interface
|
|
12
|
-
import type { PeerStore } from '@libp2p/interface
|
|
11
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
12
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
13
13
|
import type { Datastore } from 'interface-datastore'
|
|
14
14
|
|
|
15
15
|
const log = logger('libp2p:kad-dht:rpc:handlers:get-value')
|
package/src/rpc/handlers/ping.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
2
|
import type { Message } from '../../message/index.js'
|
|
3
3
|
import type { DHTMessageHandler } from '../index.js'
|
|
4
|
-
import type { PeerId } from '@libp2p/interface
|
|
4
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
5
5
|
|
|
6
6
|
const log = logger('libp2p:kad-dht:rpc:handlers:ping')
|
|
7
7
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { type Logger, logger } from '@libp2p/logger'
|
|
3
|
-
import { verifyRecord } from '
|
|
3
|
+
import { verifyRecord } from '../../record/validators.js'
|
|
4
4
|
import { bufferToRecordKey } from '../../utils.js'
|
|
5
5
|
import type { Validators } from '../../index.js'
|
|
6
6
|
import type { Message } from '../../message/index.js'
|
|
7
7
|
import type { DHTMessageHandler } from '../index.js'
|
|
8
|
-
import type { PeerId } from '@libp2p/interface
|
|
8
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
9
9
|
import type { Datastore } from 'interface-datastore'
|
|
10
10
|
|
|
11
11
|
export interface PutValueHandlerInit {
|
package/src/rpc/index.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type { Validators } from '../index.js'
|
|
|
12
12
|
import type { PeerRouting } from '../peer-routing'
|
|
13
13
|
import type { Providers } from '../providers'
|
|
14
14
|
import type { RoutingTable } from '../routing-table'
|
|
15
|
-
import type { PeerId } from '@libp2p/interface
|
|
16
|
-
import type { IncomingStreamData } from '@libp2p/interface-registrar'
|
|
15
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
16
|
+
import type { IncomingStreamData } from '@libp2p/interface-internal/registrar'
|
|
17
17
|
|
|
18
18
|
export interface DHTMessageHandler {
|
|
19
19
|
handle: (peerId: PeerId, msg: Message) => Promise<Message | undefined>
|
package/src/topology-listener.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { CustomEvent, EventEmitter } from '@libp2p/
|
|
1
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interface/events'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
-
import { createTopology } from '@libp2p/topology'
|
|
4
3
|
import type { KadDHTComponents } from '.'
|
|
5
|
-
import type { PeerId } from '@libp2p/interface
|
|
6
|
-
import type { Startable } from '@libp2p/
|
|
4
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
5
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
7
6
|
import type { Logger } from '@libp2p/logger'
|
|
8
7
|
|
|
9
8
|
export interface TopologyListenerInit {
|
|
@@ -51,7 +50,7 @@ export class TopologyListener extends EventEmitter<TopologyListenerEvents> imple
|
|
|
51
50
|
this.running = true
|
|
52
51
|
|
|
53
52
|
// register protocol with topology
|
|
54
|
-
|
|
53
|
+
this.registrarId = await this.components.registrar.register(this.protocol, {
|
|
55
54
|
onConnect: (peerId) => {
|
|
56
55
|
this.log('observed peer %p with protocol %s', peerId, this.protocol)
|
|
57
56
|
this.dispatchEvent(new CustomEvent('peer', {
|
|
@@ -59,7 +58,6 @@ export class TopologyListener extends EventEmitter<TopologyListenerEvents> imple
|
|
|
59
58
|
}))
|
|
60
59
|
}
|
|
61
60
|
})
|
|
62
|
-
this.registrarId = await this.components.registrar.register(this.protocol, topology)
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
/**
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
2
|
-
import { Libp2pRecord } from '@libp2p/record'
|
|
3
2
|
import { Key } from 'interface-datastore/key'
|
|
4
3
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
5
4
|
import isPrivateIp from 'private-ip'
|
|
@@ -7,8 +6,9 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
|
7
6
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
8
7
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
9
8
|
import { RECORD_KEY_PREFIX } from './constants.js'
|
|
10
|
-
import
|
|
11
|
-
import type {
|
|
9
|
+
import { Libp2pRecord } from './record/index.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/')
|