mirror of https://github.com/status-im/nim-eth.git
Return on getMessage failure and do address conversion afterwards
This commit is contained in:
parent
9a467225fb
commit
23aa13b03d
|
@ -411,15 +411,6 @@ proc processClient(transp: DatagramTransport, raddr: TransportAddress):
|
|||
var ip: IpAddress
|
||||
var buf = newSeq[byte]()
|
||||
|
||||
try:
|
||||
ip = raddr.address()
|
||||
except ValueError:
|
||||
# This should not be possible considering we bind to an IP address.
|
||||
error "Not a valid IpAddress"
|
||||
return
|
||||
|
||||
let a = Address(ip: ValidIpAddress.init(ip), port: raddr.port)
|
||||
|
||||
try:
|
||||
# TODO: should we use `peekMessage()` to avoid allocation?
|
||||
# TODO: This can still raise general `Exception` while it probably should
|
||||
|
@ -428,11 +419,21 @@ proc processClient(transp: DatagramTransport, raddr: TransportAddress):
|
|||
except TransportOsError as e:
|
||||
# This is likely to be local network connection issues.
|
||||
error "Transport getMessage error", exception = e.name, msg = e.msg
|
||||
return
|
||||
except Exception as e:
|
||||
if e of Defect:
|
||||
raise (ref Defect)(e)
|
||||
else: doAssert(false)
|
||||
|
||||
try:
|
||||
ip = raddr.address()
|
||||
except ValueError:
|
||||
# This should not be possible considering we bind to an IP address.
|
||||
error "Not a valid IpAddress"
|
||||
return
|
||||
|
||||
let a = Address(ip: ValidIpAddress.init(ip), port: raddr.port)
|
||||
|
||||
try:
|
||||
proto.receive(a, buf)
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue