This commit is contained in:
Dmitriy Ryajov 2020-05-29 10:25:25 -06:00
parent 7e8f0510d6
commit 132f0d7ee4
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ proc writeMsg*(conn: Connection,
let let
chunkSize = if left > MaxMsgSize: MaxMsgSize - 64 else: left chunkSize = if left > MaxMsgSize: MaxMsgSize - 64 else: left
chunk = if chunkSize > 0 : data[offset..(offset + chunkSize - 1)] else: data chunk = if chunkSize > 0 : data[offset..(offset + chunkSize - 1)] else: data
## write lenght prefixed ## write length prefixed
var buf = initVBuffer() var buf = initVBuffer()
buf.writePBVarint(id shl 3 or ord(msgType).uint64) buf.writePBVarint(id shl 3 or ord(msgType).uint64)
buf.writePBVarint(chunkSize.uint64) # size should be always sent buf.writePBVarint(chunkSize.uint64) # size should be always sent

View File

@ -44,7 +44,7 @@ proc writeLp*(s: StreamTransport, msg: string | seq[byte]): Future[int] {.gcsafe
result = s.write(buf.buffer) result = s.write(buf.buffer)
proc readLp*(s: StreamTransport): Future[seq[byte]] {.async, gcsafe.} = proc readLp*(s: StreamTransport): Future[seq[byte]] {.async, gcsafe.} =
## read lenght prefixed msg ## read length prefixed msg
var var
size: uint size: uint
length: int length: int