mirror of
https://github.com/codex-storage/nim-codex-dht.git
synced 2025-01-09 19:35:45 +00:00
add debugPrintLoop to print neighborhood info
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
0825d887ea
commit
706cb50041
@ -126,6 +126,7 @@ const
|
|||||||
RevalidateMax = 10000 ## Revalidation of a peer is done between min and max milliseconds.
|
RevalidateMax = 10000 ## Revalidation of a peer is done between min and max milliseconds.
|
||||||
## value in milliseconds
|
## value in milliseconds
|
||||||
IpMajorityInterval = 5.minutes ## Interval for checking the latest IP:Port
|
IpMajorityInterval = 5.minutes ## Interval for checking the latest IP:Port
|
||||||
|
DebugPrintInterval = 5.minutes ## Interval to print neighborhood with stats
|
||||||
## majority and updating this when SPR auto update is set.
|
## majority and updating this when SPR auto update is set.
|
||||||
InitialLookups = 1 ## Amount of lookups done when populating the routing table
|
InitialLookups = 1 ## Amount of lookups done when populating the routing table
|
||||||
ResponseTimeout* = 1.seconds ## timeout for the response of a request-response
|
ResponseTimeout* = 1.seconds ## timeout for the response of a request-response
|
||||||
@ -167,6 +168,7 @@ type
|
|||||||
refreshLoop: Future[void]
|
refreshLoop: Future[void]
|
||||||
revalidateLoop: Future[void]
|
revalidateLoop: Future[void]
|
||||||
ipMajorityLoop: Future[void]
|
ipMajorityLoop: Future[void]
|
||||||
|
debugPrintLoop: Future[void]
|
||||||
lastLookup: chronos.Moment
|
lastLookup: chronos.Moment
|
||||||
bootstrapRecords*: seq[SignedPeerRecord]
|
bootstrapRecords*: seq[SignedPeerRecord]
|
||||||
ipVote: IpVote
|
ipVote: IpVote
|
||||||
@ -1039,6 +1041,17 @@ proc ipMajorityLoop(d: Protocol) {.async.} =
|
|||||||
trace "ipMajorityLoop canceled"
|
trace "ipMajorityLoop canceled"
|
||||||
trace "ipMajorityLoop exited!"
|
trace "ipMajorityLoop exited!"
|
||||||
|
|
||||||
|
proc debugPrintLoop(d: Protocol) {.async.} =
|
||||||
|
## Loop which prints the neighborhood with stats
|
||||||
|
while true:
|
||||||
|
await sleepAsync(DebugPrintInterval)
|
||||||
|
for b in d.routingTable.buckets:
|
||||||
|
debug "bucket", depth = b.getDepth,
|
||||||
|
len = b.nodes.len, standby = b.replacementLen
|
||||||
|
for n in b.nodes:
|
||||||
|
debug "node", n, rttMin = n.stats.rttMin.int, rttAvg = n.stats.rttAvg.int,
|
||||||
|
bwMaxMbps = (n.stats.bwMax / 1e6).round(3), bwAvgMbps = (n.stats.bwAvg / 1e6).round(3)
|
||||||
|
|
||||||
func init*(
|
func init*(
|
||||||
T: type DiscoveryConfig,
|
T: type DiscoveryConfig,
|
||||||
tableIpLimit: uint,
|
tableIpLimit: uint,
|
||||||
@ -1176,6 +1189,7 @@ proc start*(d: Protocol) {.async.} =
|
|||||||
d.refreshLoop = refreshLoop(d)
|
d.refreshLoop = refreshLoop(d)
|
||||||
d.revalidateLoop = revalidateLoop(d)
|
d.revalidateLoop = revalidateLoop(d)
|
||||||
d.ipMajorityLoop = ipMajorityLoop(d)
|
d.ipMajorityLoop = ipMajorityLoop(d)
|
||||||
|
d.debugPrintLoop = debugPrintLoop(d)
|
||||||
|
|
||||||
await d.providers.start()
|
await d.providers.start()
|
||||||
|
|
||||||
|
@ -180,6 +180,8 @@ proc midpoint(k: KBucket): NodeId =
|
|||||||
|
|
||||||
proc len(k: KBucket): int = k.nodes.len
|
proc len(k: KBucket): int = k.nodes.len
|
||||||
|
|
||||||
|
proc replacementLen*(k: KBucket): int = k.replacementCache.len
|
||||||
|
|
||||||
proc tail(k: KBucket): Node = k.nodes[high(k.nodes)]
|
proc tail(k: KBucket): Node = k.nodes[high(k.nodes)]
|
||||||
|
|
||||||
proc ipLimitInc(r: var RoutingTable, b: KBucket, n: Node): bool =
|
proc ipLimitInc(r: var RoutingTable, b: KBucket, n: Node): bool =
|
||||||
@ -281,6 +283,9 @@ proc computeSharedPrefixBits(nodes: openArray[NodeId]): int =
|
|||||||
# Reaching this would mean that all node ids are equal.
|
# Reaching this would mean that all node ids are equal.
|
||||||
doAssert(false, "Unable to calculate number of shared prefix bits")
|
doAssert(false, "Unable to calculate number of shared prefix bits")
|
||||||
|
|
||||||
|
proc getDepth*(b: KBucket) : int =
|
||||||
|
computeSharedPrefixBits(@[b.istart, b.iend])
|
||||||
|
|
||||||
proc init*(T: type RoutingTable, localNode: Node, bitsPerHop = DefaultBitsPerHop,
|
proc init*(T: type RoutingTable, localNode: Node, bitsPerHop = DefaultBitsPerHop,
|
||||||
ipLimits = DefaultTableIpLimits, rng: ref HmacDrbgContext,
|
ipLimits = DefaultTableIpLimits, rng: ref HmacDrbgContext,
|
||||||
distanceCalculator = XorDistanceCalculator): T =
|
distanceCalculator = XorDistanceCalculator): T =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user