Revalidate loop fix (#60)

* Sets lower limit in revalidation loop timeout.

* Moves up RevalidateMin
This commit is contained in:
Ben Bierens 2023-06-09 10:32:45 +02:00 committed by GitHub
parent 4375b92298
commit 348cb0f1ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -121,7 +121,8 @@ const
MaxNodesPerMessage = 3 ## Maximum amount of SPRs per individual Nodes message
RefreshInterval = 5.minutes ## Interval of launching a random query to
## refresh the routing table.
RevalidateMax = 10000 ## Revalidation of a peer is done between 0 and this
RevalidateMin = 5000
RevalidateMax = 10000 ## Revalidation of a peer is done between min and max milliseconds.
## value in milliseconds
IpMajorityInterval = 5.minutes ## Interval for checking the latest IP:Port
## majority and updating this when SPR auto update is set.
@ -937,7 +938,8 @@ proc revalidateLoop(d: Protocol) {.async.} =
## message.
try:
while true:
await sleepAsync(milliseconds(d.rng[].rand(RevalidateMax)))
let revalidateTimeout = RevalidateMin + d.rng[].rand(RevalidateMax - RevalidateMin)
await sleepAsync(milliseconds(revalidateTimeout))
let n = d.routingTable.nodeToRevalidate()
if not n.isNil:
traceAsyncErrors d.revalidateNode(n)