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?
|
||||
let buf = try: transp.getMessage()
|
||||
except TransportOsError as e:
|
||||
except TransportError as e:
|
||||
# This is likely to be local network connection issues.
|
||||
warn "Transport getMessage", exception = e.name, msg = e.msg
|
||||
return
|
||||
|
|
|
@ -59,7 +59,7 @@ proc talkReqDirect(
|
|||
reqId = RequestId.init(p.rng[])
|
||||
message = encodeMessage(
|
||||
TalkReqMessage(protocol: protocol, request: request), reqId)
|
||||
(data, nonce) = encodeMessagePacket(
|
||||
(data, _) = encodeMessagePacket(
|
||||
p.rng[], p.codec, n.nodeId, n.address, message)
|
||||
|
||||
trace "Send message packet",
|
||||
|
|
|
@ -67,7 +67,8 @@ proc processDatagram(transp: DatagramTransport, raddr: TransportAddress):
|
|||
let router = getUserData[UtpRouter[TransportAddress]](transp)
|
||||
# TODO: should we use `peekMessage()` to avoid allocation?
|
||||
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.
|
||||
return
|
||||
await processIncomingBytes[TransportAddress](router, buf, raddr)
|
||||
|
|
|
@ -360,4 +360,4 @@ proc shutdownWait*[A](r: UtpRouter[A]) {.async.} =
|
|||
activeSockets.add(s)
|
||||
|
||||
for s in activeSockets:
|
||||
yield s.destroyWait()
|
||||
await s.destroyWait()
|
||||
|
|
|
@ -623,7 +623,7 @@ proc checkTimeouts(socket: UtpSocket) =
|
|||
socket.slowStart = true
|
||||
|
||||
# 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)
|
||||
|
||||
let oldestPacketSeqNr = socket.seqNr - socket.curWindowPackets
|
||||
|
@ -673,7 +673,7 @@ proc handleDataWrite(socket: UtpSocket, data: seq[byte]): int =
|
|||
let lastIndex = i + pSize - 1
|
||||
let lastOrEnd = min(lastIndex, endIndex)
|
||||
let dataSlice = data[i..lastOrEnd]
|
||||
let payloadLength = uint32(len(dataSlice))
|
||||
let payloadLength = uint32(len(dataSlice))
|
||||
if (socket.outBufferBytes + payloadLength <= socket.socketConfig.optSndBuffer):
|
||||
let wndSize = socket.getRcvWindowSize()
|
||||
let dataPacket =
|
||||
|
@ -995,8 +995,6 @@ proc selectiveAckPackets(
|
|||
dec bits
|
||||
continue
|
||||
|
||||
let pkt = maybePacket.unsafeGet()
|
||||
|
||||
if bitSet:
|
||||
debug "Packet acked by selective ack",
|
||||
pkSeqNr = v
|
||||
|
|
|
@ -46,7 +46,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||
|
||||
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
|
||||
check:
|
||||
|
@ -81,7 +81,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
|
||||
# constructor which uses connection callback and user data pointer as ref
|
||||
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
|
||||
check:
|
||||
|
@ -111,7 +111,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||
|
||||
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
|
||||
check:
|
||||
|
@ -154,7 +154,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
utpProtId,
|
||||
registerIncomingSocketCallback(queue),
|
||||
socketConfig = SocketConfig.init(lowSynTimeout))
|
||||
utp2 =
|
||||
utp2 {.used.} =
|
||||
UtpDiscv5Protocol.new(
|
||||
node2,
|
||||
utpProtId,
|
||||
|
@ -195,7 +195,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
rng, PrivateKey.random(rng[]), localAddress(20303))
|
||||
|
||||
utp1 = UtpDiscv5Protocol.new(node1, utpProtId, registerIncomingSocketCallback(queue))
|
||||
utp2 = UtpDiscv5Protocol.new(
|
||||
utp2 {.used.} = UtpDiscv5Protocol.new(
|
||||
node2,
|
||||
utpProtId,
|
||||
registerIncomingSocketCallback(queue),
|
||||
|
|
|
@ -223,7 +223,7 @@ procSuite "Utp protocol over udp tests":
|
|||
# this future will be completed when we called accepted connection callback
|
||||
await server2Called.wait()
|
||||
|
||||
yield futSock
|
||||
discard (await futSock)
|
||||
|
||||
check:
|
||||
futSock.finished() and (not futSock.failed()) and (not futSock.cancelled())
|
||||
|
|
|
@ -56,7 +56,7 @@ procSuite "Utp router unit tests":
|
|||
initialRemoteSeq: uint16): (UtpSocket[int], Packet)=
|
||||
let connectFuture = router.connectTo(remote)
|
||||
|
||||
let (initialPacket, sender) = await pq.get()
|
||||
let (initialPacket, _) = await pq.get()
|
||||
|
||||
check:
|
||||
initialPacket.header.pType == ST_SYN
|
||||
|
@ -440,7 +440,7 @@ procSuite "Utp router unit tests":
|
|||
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
||||
router.sendCb = initTestSnd(pq)
|
||||
|
||||
let (outgoingSocket, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
||||
let (_, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
||||
|
||||
check:
|
||||
router.len() == 1
|
||||
|
|
|
@ -444,8 +444,8 @@ procSuite "uTP socket tests":
|
|||
|
||||
outgoingSocket.destroy()
|
||||
|
||||
yield writeFut1
|
||||
yield writeFut2
|
||||
discard await writeFut1
|
||||
discard await writeFut2
|
||||
|
||||
check:
|
||||
writeFut1.completed()
|
||||
|
@ -485,13 +485,12 @@ procSuite "uTP socket tests":
|
|||
|
||||
await outgoingSocket.processPacket(someAckFromRemote)
|
||||
|
||||
yield writeFut1
|
||||
yield writeFut2
|
||||
yield writeFut3
|
||||
discard await writeFut1
|
||||
discard await writeFut3
|
||||
|
||||
check:
|
||||
writeFut1.completed()
|
||||
writeFut2.cancelled()
|
||||
writeFut2.cancelled() # TODO: This might not always be the case?
|
||||
writeFut3.completed()
|
||||
|
||||
let p1 = await q.get()
|
||||
|
@ -1250,7 +1249,7 @@ procSuite "uTP socket tests":
|
|||
# write should progress
|
||||
await outgoingSocket.processPacket(someAckFromRemote)
|
||||
|
||||
yield writeFut2
|
||||
discard await writeFut2
|
||||
|
||||
let secondPacket = await q.get()
|
||||
|
||||
|
|
Loading…
Reference in New Issue