mirror of https://github.com/status-im/nim-eth.git
Fix a bunch of compiler hints and warnings in uTP and discv5 (#652)
* Fix a bunch of compiler hints and warnings in uTP and discv5 * Leave in the cancel() for now
This commit is contained in:
parent
0fc5dc03c5
commit
11049fb87d
|
@ -470,7 +470,7 @@ proc processClient(transp: DatagramTransport, raddr: TransportAddress):
|
||||||
|
|
||||||
# TODO: should we use `peekMessage()` to avoid allocation?
|
# TODO: should we use `peekMessage()` to avoid allocation?
|
||||||
let buf = try: transp.getMessage()
|
let buf = try: transp.getMessage()
|
||||||
except TransportOsError as e:
|
except TransportError as e:
|
||||||
# This is likely to be local network connection issues.
|
# This is likely to be local network connection issues.
|
||||||
warn "Transport getMessage", exception = e.name, msg = e.msg
|
warn "Transport getMessage", exception = e.name, msg = e.msg
|
||||||
return
|
return
|
||||||
|
|
|
@ -59,7 +59,7 @@ proc talkReqDirect(
|
||||||
reqId = RequestId.init(p.rng[])
|
reqId = RequestId.init(p.rng[])
|
||||||
message = encodeMessage(
|
message = encodeMessage(
|
||||||
TalkReqMessage(protocol: protocol, request: request), reqId)
|
TalkReqMessage(protocol: protocol, request: request), reqId)
|
||||||
(data, nonce) = encodeMessagePacket(
|
(data, _) = encodeMessagePacket(
|
||||||
p.rng[], p.codec, n.nodeId, n.address, message)
|
p.rng[], p.codec, n.nodeId, n.address, message)
|
||||||
|
|
||||||
trace "Send message packet",
|
trace "Send message packet",
|
||||||
|
|
|
@ -67,7 +67,8 @@ proc processDatagram(transp: DatagramTransport, raddr: TransportAddress):
|
||||||
let router = getUserData[UtpRouter[TransportAddress]](transp)
|
let router = getUserData[UtpRouter[TransportAddress]](transp)
|
||||||
# TODO: should we use `peekMessage()` to avoid allocation?
|
# TODO: should we use `peekMessage()` to avoid allocation?
|
||||||
let buf = try: transp.getMessage()
|
let buf = try: transp.getMessage()
|
||||||
except TransportOsError as e:
|
except TransportError as e:
|
||||||
|
trace "Error reading datagram msg: ", error = e.msg
|
||||||
# This is likely to be local network connection issues.
|
# This is likely to be local network connection issues.
|
||||||
return
|
return
|
||||||
await processIncomingBytes[TransportAddress](router, buf, raddr)
|
await processIncomingBytes[TransportAddress](router, buf, raddr)
|
||||||
|
|
|
@ -360,4 +360,4 @@ proc shutdownWait*[A](r: UtpRouter[A]) {.async.} =
|
||||||
activeSockets.add(s)
|
activeSockets.add(s)
|
||||||
|
|
||||||
for s in activeSockets:
|
for s in activeSockets:
|
||||||
yield s.destroyWait()
|
await s.destroyWait()
|
||||||
|
|
|
@ -623,7 +623,7 @@ proc checkTimeouts(socket: UtpSocket) =
|
||||||
socket.slowStart = true
|
socket.slowStart = true
|
||||||
|
|
||||||
# Note: with selective acks enabled, every selectively acked packet resets
|
# Note: with selective acks enabled, every selectively acked packet resets
|
||||||
# the timeout timer and removes te packet from the outBuffer.
|
# the timeout timer and removes the packet from the outBuffer.
|
||||||
markAllPacketAsLost(socket)
|
markAllPacketAsLost(socket)
|
||||||
|
|
||||||
let oldestPacketSeqNr = socket.seqNr - socket.curWindowPackets
|
let oldestPacketSeqNr = socket.seqNr - socket.curWindowPackets
|
||||||
|
@ -995,8 +995,6 @@ proc selectiveAckPackets(
|
||||||
dec bits
|
dec bits
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let pkt = maybePacket.unsafeGet()
|
|
||||||
|
|
||||||
if bitSet:
|
if bitSet:
|
||||||
debug "Packet acked by selective ack",
|
debug "Packet acked by selective ack",
|
||||||
pkSeqNr = v
|
pkSeqNr = v
|
||||||
|
|
|
@ -46,7 +46,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
||||||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||||
|
|
||||||
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
||||||
utp2 = UtpDiscv5Protocol.new(node2, utpProtId, registerIncomingSocketCallback(queue))
|
utp2 {.used.} = UtpDiscv5Protocol.new(node2, utpProtId, registerIncomingSocketCallback(queue))
|
||||||
|
|
||||||
# nodes must have session between each other
|
# nodes must have session between each other
|
||||||
check:
|
check:
|
||||||
|
@ -81,7 +81,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
||||||
|
|
||||||
# constructor which uses connection callback and user data pointer as ref
|
# constructor which uses connection callback and user data pointer as ref
|
||||||
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, cbUserData, queue)
|
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, cbUserData, queue)
|
||||||
utp2 = UtpDiscv5Protocol.new(node2, utpProtId, cbUserData, queue)
|
utp2 {.used.} = UtpDiscv5Protocol.new(node2, utpProtId, cbUserData, queue)
|
||||||
|
|
||||||
# nodes must have session between each other
|
# nodes must have session between each other
|
||||||
check:
|
check:
|
||||||
|
@ -111,7 +111,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
||||||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||||
|
|
||||||
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
||||||
utp2 = UtpDiscv5Protocol.new(node2, utpProtId, registerIncomingSocketCallback(queue))
|
utp2 {.used.} = UtpDiscv5Protocol.new(node2, utpProtId, registerIncomingSocketCallback(queue))
|
||||||
|
|
||||||
# nodes must have session between each other
|
# nodes must have session between each other
|
||||||
check:
|
check:
|
||||||
|
@ -154,7 +154,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
||||||
utpProtId,
|
utpProtId,
|
||||||
registerIncomingSocketCallback(queue),
|
registerIncomingSocketCallback(queue),
|
||||||
socketConfig = SocketConfig.init(lowSynTimeout))
|
socketConfig = SocketConfig.init(lowSynTimeout))
|
||||||
utp2 =
|
utp2 {.used.} =
|
||||||
UtpDiscv5Protocol.new(
|
UtpDiscv5Protocol.new(
|
||||||
node2,
|
node2,
|
||||||
utpProtId,
|
utpProtId,
|
||||||
|
@ -195,7 +195,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
||||||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||||
|
|
||||||
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
||||||
utp2 = UtpDiscv5Protocol.new(
|
utp2 {.used.} = UtpDiscv5Protocol.new(
|
||||||
node2,
|
node2,
|
||||||
utpProtId,
|
utpProtId,
|
||||||
registerIncomingSocketCallback(queue),
|
registerIncomingSocketCallback(queue),
|
||||||
|
|
|
@ -223,7 +223,7 @@ procSuite "Utp protocol over udp tests":
|
||||||
# this future will be completed when we called accepted connection callback
|
# this future will be completed when we called accepted connection callback
|
||||||
await server2Called.wait()
|
await server2Called.wait()
|
||||||
|
|
||||||
yield futSock
|
discard (await futSock)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
futSock.finished() and (not futSock.failed()) and (not futSock.cancelled())
|
futSock.finished() and (not futSock.failed()) and (not futSock.cancelled())
|
||||||
|
|
|
@ -56,7 +56,7 @@ procSuite "Utp router unit tests":
|
||||||
initialRemoteSeq: uint16): (UtpSocket[int], Packet)=
|
initialRemoteSeq: uint16): (UtpSocket[int], Packet)=
|
||||||
let connectFuture = router.connectTo(remote)
|
let connectFuture = router.connectTo(remote)
|
||||||
|
|
||||||
let (initialPacket, sender) = await pq.get()
|
let (initialPacket, _) = await pq.get()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
initialPacket.header.pType == ST_SYN
|
initialPacket.header.pType == ST_SYN
|
||||||
|
@ -440,7 +440,7 @@ procSuite "Utp router unit tests":
|
||||||
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
||||||
router.sendCb = initTestSnd(pq)
|
router.sendCb = initTestSnd(pq)
|
||||||
|
|
||||||
let (outgoingSocket, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
let (_, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
router.len() == 1
|
router.len() == 1
|
||||||
|
|
|
@ -444,8 +444,8 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
outgoingSocket.destroy()
|
outgoingSocket.destroy()
|
||||||
|
|
||||||
yield writeFut1
|
discard await writeFut1
|
||||||
yield writeFut2
|
discard await writeFut2
|
||||||
|
|
||||||
check:
|
check:
|
||||||
writeFut1.completed()
|
writeFut1.completed()
|
||||||
|
@ -485,13 +485,12 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
await outgoingSocket.processPacket(someAckFromRemote)
|
await outgoingSocket.processPacket(someAckFromRemote)
|
||||||
|
|
||||||
yield writeFut1
|
discard await writeFut1
|
||||||
yield writeFut2
|
discard await writeFut3
|
||||||
yield writeFut3
|
|
||||||
|
|
||||||
check:
|
check:
|
||||||
writeFut1.completed()
|
writeFut1.completed()
|
||||||
writeFut2.cancelled()
|
writeFut2.cancelled() # TODO: This might not always be the case?
|
||||||
writeFut3.completed()
|
writeFut3.completed()
|
||||||
|
|
||||||
let p1 = await q.get()
|
let p1 = await q.get()
|
||||||
|
@ -1250,7 +1249,7 @@ procSuite "uTP socket tests":
|
||||||
# write should progress
|
# write should progress
|
||||||
await outgoingSocket.processPacket(someAckFromRemote)
|
await outgoingSocket.processPacket(someAckFromRemote)
|
||||||
|
|
||||||
yield writeFut2
|
discard await writeFut2
|
||||||
|
|
||||||
let secondPacket = await q.get()
|
let secondPacket = await q.get()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue