@libp2p/kad-dht 14.2.15-4c64bd06d → 14.2.15-4f37aff53
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 +20 -4
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts +22 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +20 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/kad-dht.d.ts.map +1 -1
- package/dist/src/kad-dht.js +2 -1
- package/dist/src/kad-dht.js.map +1 -1
- package/dist/src/routing-table/index.d.ts +2 -0
- package/dist/src/routing-table/index.d.ts.map +1 -1
- package/dist/src/routing-table/index.js +6 -15
- package/dist/src/routing-table/index.js.map +1 -1
- package/package.json +12 -11
- package/src/index.ts +22 -4
- package/src/kad-dht.ts +2 -1
- package/src/routing-table/index.ts +8 -18
|
@@ -3,14 +3,13 @@ import { AdaptiveTimeout } from '@libp2p/utils/adaptive-timeout'
|
|
|
3
3
|
import { PeerQueue } from '@libp2p/utils/peer-queue'
|
|
4
4
|
import { anySignal } from 'any-signal'
|
|
5
5
|
import parallel from 'it-parallel'
|
|
6
|
-
import { EventTypes } from '../index.js'
|
|
7
|
-
import { MessageType } from '../message/dht.js'
|
|
8
6
|
import * as utils from '../utils.js'
|
|
9
7
|
import { ClosestPeers } from './closest-peers.js'
|
|
10
8
|
import { KBucket, isLeafBucket } from './k-bucket.js'
|
|
11
9
|
import type { Bucket, LeafBucket, Peer } from './k-bucket.js'
|
|
12
10
|
import type { Network } from '../network.js'
|
|
13
11
|
import type { AbortOptions, ComponentLogger, CounterGroup, Logger, Metric, Metrics, PeerId, PeerStore, Startable, Stream } from '@libp2p/interface'
|
|
12
|
+
import type { Ping } from '@libp2p/ping'
|
|
14
13
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils/adaptive-timeout'
|
|
15
14
|
|
|
16
15
|
export const KBUCKET_SIZE = 20
|
|
@@ -59,6 +58,7 @@ export interface RoutingTableComponents {
|
|
|
59
58
|
peerStore: PeerStore
|
|
60
59
|
metrics?: Metrics
|
|
61
60
|
logger: ComponentLogger
|
|
61
|
+
ping: Ping
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export interface RoutingTableEvents {
|
|
@@ -379,24 +379,14 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
379
379
|
|
|
380
380
|
try {
|
|
381
381
|
this.log('pinging contact %p', contact.peerId)
|
|
382
|
+
await this.components.ping.ping(contact.peerId, options)
|
|
383
|
+
this.log('contact %p ping ok', contact.peerId)
|
|
382
384
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
this.log('contact %p ping ok', contact.peerId)
|
|
387
|
-
|
|
388
|
-
this.safeDispatchEvent('peer:ping', {
|
|
389
|
-
detail: contact.peerId
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
return true
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return false
|
|
396
|
-
}
|
|
397
|
-
}
|
|
385
|
+
this.safeDispatchEvent('peer:ping', {
|
|
386
|
+
detail: contact.peerId
|
|
387
|
+
})
|
|
398
388
|
|
|
399
|
-
return
|
|
389
|
+
return true
|
|
400
390
|
} catch (err: any) {
|
|
401
391
|
this.log('error pinging old contact %p - %e', contact.peerId, err)
|
|
402
392
|
stream?.abort(err)
|