Minor improvements from pr comments (#455)

This commit is contained in:
KonradStaniec 2021-12-28 08:08:05 +01:00 committed by GitHub
parent 42e257796f
commit 664072fff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -168,7 +168,7 @@ proc decodePacket*(bytes: openArray[byte]): Result[Packet, string] =
if (receivedBytesLength == minimalHeaderSize): if (receivedBytesLength == minimalHeaderSize):
@[] @[]
else: else:
bytes[20..^1] bytes[minimalHeaderSize..^1]
return ok(Packet(header: header, eack: none[SelectiveAckExtension](), payload: payload)) return ok(Packet(header: header, eack: none[SelectiveAckExtension](), payload: payload))
else: else:
@ -189,14 +189,14 @@ proc decodePacket*(bytes: openArray[byte]): Result[Packet, string] =
let extension = SelectiveAckExtension( let extension = SelectiveAckExtension(
acks: [bytes[22], bytes[23], bytes[24], bytes[25]] acks: toArray(4, bytes.toOpenArray(22, 25))
) )
let payload = let payload =
if (receivedBytesLength == minimalHeaderSizeWithSelectiveAck): if (receivedBytesLength == minimalHeaderSizeWithSelectiveAck):
@[] @[]
else: else:
bytes[26..^1] bytes[minimalHeaderSizeWithSelectiveAck..^1]
return ok(Packet(header: header, eack: some(extension), payload: payload)) return ok(Packet(header: header, eack: some(extension), payload: payload))