mirror of
https://github.com/codex-storage/nim-codex-dht.git
synced 2025-01-24 10:51:20 +00:00
metrics: add discovery_routing_table_buckets
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
b7b04ed9e4
commit
4d2250477e
@ -16,6 +16,8 @@ export options
|
|||||||
|
|
||||||
declarePublicGauge discovery_routing_table_nodes,
|
declarePublicGauge discovery_routing_table_nodes,
|
||||||
"Discovery routing table nodes", labels = ["state"]
|
"Discovery routing table nodes", labels = ["state"]
|
||||||
|
declarePublicGauge discovery_routing_table_buckets,
|
||||||
|
"Discovery routing table: number of buckets"
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "discv5 routingtable"
|
topics = "discv5 routingtable"
|
||||||
@ -286,6 +288,7 @@ proc init*(T: type RoutingTable, localNode: Node, bitsPerHop = DefaultBitsPerHop
|
|||||||
distanceCalculator = XorDistanceCalculator): T =
|
distanceCalculator = XorDistanceCalculator): T =
|
||||||
## Initialize the routing table for provided `Node` and bitsPerHop value.
|
## Initialize the routing table for provided `Node` and bitsPerHop value.
|
||||||
## `bitsPerHop` is default set to 5 as recommended by original Kademlia paper.
|
## `bitsPerHop` is default set to 5 as recommended by original Kademlia paper.
|
||||||
|
discovery_routing_table_buckets.inc()
|
||||||
RoutingTable(
|
RoutingTable(
|
||||||
localNode: localNode,
|
localNode: localNode,
|
||||||
buckets: @[KBucket.new(0.u256, high(UInt256), ipLimits.bucketIpLimit)],
|
buckets: @[KBucket.new(0.u256, high(UInt256), ipLimits.bucketIpLimit)],
|
||||||
@ -299,6 +302,7 @@ proc splitBucket(r: var RoutingTable, index: int) =
|
|||||||
let (a, b) = bucket.split()
|
let (a, b) = bucket.split()
|
||||||
r.buckets[index] = a
|
r.buckets[index] = a
|
||||||
r.buckets.insert(b, index + 1)
|
r.buckets.insert(b, index + 1)
|
||||||
|
discovery_routing_table_buckets.inc()
|
||||||
|
|
||||||
proc bucketForNode(r: RoutingTable, id: NodeId): KBucket =
|
proc bucketForNode(r: RoutingTable, id: NodeId): KBucket =
|
||||||
result = binaryGetBucketForNode(r.buckets, id)
|
result = binaryGetBucketForNode(r.buckets, id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user