@libp2p/kad-dht 13.1.1-d9c7e0f7e → 13.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 +2 -2
- package/dist/src/network.d.ts +1 -0
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +9 -0
- package/dist/src/network.js.map +1 -1
- package/dist/src/query/manager.d.ts +1 -2
- package/dist/src/query/manager.d.ts.map +1 -1
- package/dist/src/query/manager.js +11 -16
- package/dist/src/query/manager.js.map +1 -1
- package/dist/src/routing-table/index.d.ts.map +1 -1
- package/dist/src/routing-table/index.js +7 -2
- package/dist/src/routing-table/index.js.map +1 -1
- package/dist/typedoc-urls.json +56 -0
- package/package.json +11 -11
- package/src/network.ts +17 -1
- package/src/query/manager.ts +16 -21
- package/src/routing-table/index.ts +10 -3
|
@@ -5,7 +5,7 @@ import { pbStream } from 'it-protobuf-stream'
|
|
|
5
5
|
import { Message, MessageType } from '../message/dht.js'
|
|
6
6
|
import * as utils from '../utils.js'
|
|
7
7
|
import { KBucket, isLeafBucket, type Bucket, type PingEventDetails } from './k-bucket.js'
|
|
8
|
-
import type { ComponentLogger, Logger, Metric, Metrics, PeerId, PeerStore, Startable, Stream } from '@libp2p/interface'
|
|
8
|
+
import type { ComponentLogger, CounterGroup, Logger, Metric, Metrics, PeerId, PeerStore, Startable, Stream } from '@libp2p/interface'
|
|
9
9
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
10
10
|
|
|
11
11
|
export const KAD_CLOSE_TAG_NAME = 'kad-close'
|
|
@@ -64,6 +64,7 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
64
64
|
routingTableKadBucketTotal: Metric
|
|
65
65
|
routingTableKadBucketAverageOccupancy: Metric
|
|
66
66
|
routingTableKadBucketMaxDepth: Metric
|
|
67
|
+
kadBucketEvents: CounterGroup<'ping' | 'ping_error' | 'peer_added' | 'peer_removed'>
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
constructor (components: RoutingTableComponents, init: RoutingTableInit) {
|
|
@@ -95,7 +96,8 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
95
96
|
routingTableSize: this.components.metrics.registerMetric(`${init.logPrefix.replaceAll(':', '_')}_routing_table_size`),
|
|
96
97
|
routingTableKadBucketTotal: this.components.metrics.registerMetric(`${init.logPrefix.replaceAll(':', '_')}_routing_table_kad_bucket_total`),
|
|
97
98
|
routingTableKadBucketAverageOccupancy: this.components.metrics.registerMetric(`${init.logPrefix.replaceAll(':', '_')}_routing_table_kad_bucket_average_occupancy`),
|
|
98
|
-
routingTableKadBucketMaxDepth: this.components.metrics.registerMetric(`${init.logPrefix.replaceAll(':', '_')}_routing_table_kad_bucket_max_depth`)
|
|
99
|
+
routingTableKadBucketMaxDepth: this.components.metrics.registerMetric(`${init.logPrefix.replaceAll(':', '_')}_routing_table_kad_bucket_max_depth`),
|
|
100
|
+
kadBucketEvents: this.components.metrics.registerCounterGroup(`${init.logPrefix.replaceAll(':', '_')}_kad_bucket_events_total`)
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -121,7 +123,10 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
121
123
|
|
|
122
124
|
// test whether to evict peers
|
|
123
125
|
kBuck.addEventListener('ping', (evt) => {
|
|
126
|
+
this.metrics?.kadBucketEvents.increment({ ping: true })
|
|
127
|
+
|
|
124
128
|
this._onPing(evt).catch(err => {
|
|
129
|
+
this.metrics?.kadBucketEvents.increment({ ping_error: true })
|
|
125
130
|
this.log.error('could not process k-bucket ping event', err)
|
|
126
131
|
})
|
|
127
132
|
})
|
|
@@ -195,11 +200,13 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
195
200
|
kBuck.addEventListener('added', (evt) => {
|
|
196
201
|
updatePeerTags()
|
|
197
202
|
|
|
203
|
+
this.metrics?.kadBucketEvents.increment({ peer_added: true })
|
|
198
204
|
this.safeDispatchEvent('peer:add', { detail: evt.detail.peerId })
|
|
199
205
|
})
|
|
200
206
|
kBuck.addEventListener('removed', (evt) => {
|
|
201
207
|
updatePeerTags()
|
|
202
208
|
|
|
209
|
+
this.metrics?.kadBucketEvents.increment({ peer_removed: true })
|
|
203
210
|
this.safeDispatchEvent('peer:remove', { detail: evt.detail.peerId })
|
|
204
211
|
})
|
|
205
212
|
}
|
|
@@ -271,7 +278,7 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
|
|
|
271
278
|
|
|
272
279
|
return false
|
|
273
280
|
} finally {
|
|
274
|
-
this.
|
|
281
|
+
this.updateMetrics()
|
|
275
282
|
}
|
|
276
283
|
}, {
|
|
277
284
|
peerId: oldContact.peerId
|