mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-26 05:05:23 +00:00
Cosmetic improvements
This commit is contained in:
parent
e8a15aa0ce
commit
15f0153441
@ -306,14 +306,14 @@ proc disconnectAndRaise(peer: Peer,
|
||||
await peer.disconnect(r)
|
||||
raisePeerDisconnected(msg, r)
|
||||
|
||||
proc readSizePrefix(s: AsyncInputStream): Future[int] {.async.} =
|
||||
proc readSizePrefix(s: AsyncInputStream, maxSize: uint64): Future[int] {.async.} =
|
||||
trace "about to read msg size prefix"
|
||||
var parser: VarintParser[uint64, ProtoBuf]
|
||||
while s.readable:
|
||||
case parser.feedByte(s.read)
|
||||
of Done:
|
||||
let res = parser.getResult
|
||||
if res > uint64(MAX_CHUNK_SIZE):
|
||||
if res > maxSize:
|
||||
trace "size prefix outside of range", res
|
||||
return -1
|
||||
else:
|
||||
@ -326,10 +326,10 @@ proc readSizePrefix(s: AsyncInputStream): Future[int] {.async.} =
|
||||
continue
|
||||
|
||||
proc readSszValue(s: AsyncInputStream, MsgType: type): Future[MsgType] {.async.} =
|
||||
let size = await s.readSizePrefix
|
||||
let size = await s.readSizePrefix(uint64(MAX_CHUNK_SIZE))
|
||||
if size > 0 and s.readable(size):
|
||||
s.nonBlockingReads(ss):
|
||||
return ss.readValue(SSZ, MsgType)
|
||||
s.withReadableRange(size, r):
|
||||
return r.readValue(SSZ, MsgType)
|
||||
else:
|
||||
raise newException(CatchableError,
|
||||
"Failed to read an incoming message size prefix")
|
||||
|
2
vendor/nim-chronicles
vendored
2
vendor/nim-chronicles
vendored
@ -1 +1 @@
|
||||
Subproject commit af184ae47e20672b68d20e7cacd3b726533548e1
|
||||
Subproject commit bb2b58881004481a7d790f4d349d35b29cdbcac9
|
2
vendor/nim-faststreams
vendored
2
vendor/nim-faststreams
vendored
@ -1 +1 @@
|
||||
Subproject commit 8b863f7798f7e1a6a9266b88e7bca5aa0cb5ed8a
|
||||
Subproject commit dd63bbfd1cea26e9ca830a3a8fd70e5d3a0d1306
|
Loading…
x
Reference in New Issue
Block a user