mirror of https://github.com/status-im/nim-eth.git
Add own node checks before sending ping (#548)
Seems there are two occasions possible where we try to ping the own local node which causes an assert - One via the bounding - One via a received ping, which is strange in the first place but notice in a stack trace
This commit is contained in:
parent
fef47331c3
commit
64b56d866c
|
@ -443,6 +443,7 @@ proc findNode*(k: KademliaProtocol, nodesSeen: ref HashSet[Node],
|
||||||
|
|
||||||
var bondedNodes: seq[Future[bool]] = @[]
|
var bondedNodes: seq[Future[bool]] = @[]
|
||||||
for node in candidates:
|
for node in candidates:
|
||||||
|
if node != k.thisNode:
|
||||||
bondedNodes.add(k.bond(node))
|
bondedNodes.add(k.bond(node))
|
||||||
|
|
||||||
await allFutures(bondedNodes)
|
await allFutures(bondedNodes)
|
||||||
|
@ -602,6 +603,9 @@ proc recvPing*(k: KademliaProtocol, n: Node, msgHash: any)
|
||||||
k.wire.sendPong(n, msgHash)
|
k.wire.sendPong(n, msgHash)
|
||||||
|
|
||||||
if getTime() - k.lastPongReceived(n) > BOND_EXPIRATION:
|
if getTime() - k.lastPongReceived(n) > BOND_EXPIRATION:
|
||||||
|
# TODO: It is strange that this would occur, as it means our own node would
|
||||||
|
# have pinged us which should have caused an assert in the first place.
|
||||||
|
if n != k.thisNode:
|
||||||
let pingId = pingId(n, k.ping(n))
|
let pingId = pingId(n, k.ping(n))
|
||||||
|
|
||||||
let fut = if pingId in k.pongFutures:
|
let fut = if pingId in k.pongFutures:
|
||||||
|
|
Loading…
Reference in New Issue