Work-around the sizeof change in behavior introduced in Nim 1.6 (#3462)

This commit is contained in:
zah 2022-03-04 10:52:49 +02:00 committed by GitHub
parent c18cd8ee0c
commit 8967f9cf01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -733,7 +733,19 @@ proc handleIncomingStream(network: Eth2Node,
let deadline = sleepAsync RESP_TIMEOUT
let msg = if sizeof(MsgRec) > 0:
const isEmptyMsg = when MsgRec is object:
# We need nested `when` statements here, because Nim doesn't properly
# apply boolean short-circuit logic at compile time and this causes
# `totalSerializedFields` to be applied to non-object types that it
# doesn't know how to support.
when totalSerializedFields(MsgRec) == 0: true
else: false
else:
false
let msg = when isEmptyMsg:
NetRes[MsgRec].ok default(MsgRec)
else:
try:
awaitWithTimeout(readChunkPayload(s, peer, MsgRec), deadline):
returnInvalidRequest(errorMsgLit "Request full data not sent in time")
@ -743,8 +755,6 @@ proc handleIncomingStream(network: Eth2Node,
except SnappyError as err:
returnInvalidRequest err.msg
else:
NetRes[MsgRec].ok default(MsgRec)
if msg.isErr:
let (responseCode, errMsg) = case msg.error.kind

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit b464505b4dcbe2ef52d19b2cfca8f2be4ebf2c7e
Subproject commit b87fd80b0f1a4c3c3961e61fbea177ded22b34e0