mirror of https://github.com/status-im/nim-eth.git
Slightly improved logging traces for error on message responses (#364)
This commit is contained in:
parent
0ad571ab27
commit
d18ebaa570
|
@ -546,18 +546,23 @@ proc waitNodes(d: Protocol, fromNode: Node, reqId: RequestId):
|
||||||
## If one reply is lost here (timed out), others are ignored too.
|
## If one reply is lost here (timed out), others are ignored too.
|
||||||
## Same counts for out of order receival.
|
## Same counts for out of order receival.
|
||||||
var op = await d.waitMessage(fromNode, reqId)
|
var op = await d.waitMessage(fromNode, reqId)
|
||||||
if op.isSome and op.get.kind == nodes:
|
if op.isSome:
|
||||||
var res = op.get.nodes.enrs
|
if op.get.kind == nodes:
|
||||||
let total = op.get.nodes.total
|
var res = op.get.nodes.enrs
|
||||||
for i in 1 ..< total:
|
let total = op.get.nodes.total
|
||||||
op = await d.waitMessage(fromNode, reqId)
|
for i in 1 ..< total:
|
||||||
if op.isSome and op.get.kind == nodes:
|
op = await d.waitMessage(fromNode, reqId)
|
||||||
res.add(op.get.nodes.enrs)
|
if op.isSome and op.get.kind == nodes:
|
||||||
else:
|
res.add(op.get.nodes.enrs)
|
||||||
# No error on this as we received some nodes.
|
else:
|
||||||
break
|
# No error on this as we received some nodes.
|
||||||
return ok(res)
|
break
|
||||||
|
return ok(res)
|
||||||
|
else:
|
||||||
|
discovery_message_requests_outgoing.inc(labelValues = ["invalid_response"])
|
||||||
|
return err("Invalid response to find node message")
|
||||||
else:
|
else:
|
||||||
|
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
||||||
return err("Nodes message not received in time")
|
return err("Nodes message not received in time")
|
||||||
|
|
||||||
proc sendMessage*[T: SomeMessage](d: Protocol, toNode: Node, m: T):
|
proc sendMessage*[T: SomeMessage](d: Protocol, toNode: Node, m: T):
|
||||||
|
@ -586,9 +591,14 @@ proc ping*(d: Protocol, toNode: Node):
|
||||||
PingMessage(enrSeq: d.localNode.record.seqNum))
|
PingMessage(enrSeq: d.localNode.record.seqNum))
|
||||||
let resp = await d.waitMessage(toNode, reqId)
|
let resp = await d.waitMessage(toNode, reqId)
|
||||||
|
|
||||||
if resp.isSome() and resp.get().kind == pong:
|
if resp.isSome():
|
||||||
d.routingTable.setJustSeen(toNode)
|
if resp.get().kind == pong:
|
||||||
return ok(resp.get().pong)
|
d.routingTable.setJustSeen(toNode)
|
||||||
|
return ok(resp.get().pong)
|
||||||
|
else:
|
||||||
|
d.replaceNode(toNode)
|
||||||
|
discovery_message_requests_outgoing.inc(labelValues = ["invalid_response"])
|
||||||
|
return err("Invalid response to ping message")
|
||||||
else:
|
else:
|
||||||
d.replaceNode(toNode)
|
d.replaceNode(toNode)
|
||||||
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
||||||
|
@ -609,7 +619,6 @@ proc findNode*(d: Protocol, toNode: Node, distances: seq[uint32]):
|
||||||
return ok(res)
|
return ok(res)
|
||||||
else:
|
else:
|
||||||
d.replaceNode(toNode)
|
d.replaceNode(toNode)
|
||||||
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
|
||||||
return err(nodes.error)
|
return err(nodes.error)
|
||||||
|
|
||||||
proc talkreq*(d: Protocol, toNode: Node, protocol, request: seq[byte]):
|
proc talkreq*(d: Protocol, toNode: Node, protocol, request: seq[byte]):
|
||||||
|
@ -621,9 +630,14 @@ proc talkreq*(d: Protocol, toNode: Node, protocol, request: seq[byte]):
|
||||||
TalkReqMessage(protocol: protocol, request: request))
|
TalkReqMessage(protocol: protocol, request: request))
|
||||||
let resp = await d.waitMessage(toNode, reqId)
|
let resp = await d.waitMessage(toNode, reqId)
|
||||||
|
|
||||||
if resp.isSome() and resp.get().kind == talkresp:
|
if resp.isSome():
|
||||||
d.routingTable.setJustSeen(toNode)
|
if resp.get().kind == talkresp:
|
||||||
return ok(resp.get().talkresp)
|
d.routingTable.setJustSeen(toNode)
|
||||||
|
return ok(resp.get().talkresp)
|
||||||
|
else:
|
||||||
|
d.replaceNode(toNode)
|
||||||
|
discovery_message_requests_outgoing.inc(labelValues = ["invalid_response"])
|
||||||
|
return err("Invalid response to talk request message")
|
||||||
else:
|
else:
|
||||||
d.replaceNode(toNode)
|
d.replaceNode(toNode)
|
||||||
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
discovery_message_requests_outgoing.inc(labelValues = ["no_response"])
|
||||||
|
|
Loading…
Reference in New Issue