Merge branch 'master' of github.com:status-im/nim-libp2p into peer
This commit is contained in:
commit
046c693e3a
|
@ -176,12 +176,12 @@ proc write*(pb: var ProtoBuffer, field: ProtoField) =
|
||||||
|
|
||||||
proc finish*(pb: var ProtoBuffer) =
|
proc finish*(pb: var ProtoBuffer) =
|
||||||
## Prepare protobuf's buffer ``pb`` for writing to stream.
|
## Prepare protobuf's buffer ``pb`` for writing to stream.
|
||||||
var length = 0
|
|
||||||
assert(len(pb.buffer) > 0)
|
assert(len(pb.buffer) > 0)
|
||||||
if WithVarintLength in pb.options:
|
if WithVarintLength in pb.options:
|
||||||
let size = uint(len(pb.buffer) - 10)
|
let size = uint(len(pb.buffer) - 10)
|
||||||
let pos = 10 - vsizeof(length)
|
let pos = 10 - vsizeof(size)
|
||||||
let res = PB.putUVarint(pb.buffer.toOpenArray(pos, 9), length, size)
|
var usedBytes = 0
|
||||||
|
let res = PB.putUVarint(pb.buffer.toOpenArray(pos, 9), usedBytes, size)
|
||||||
assert(res == VarintStatus.Success)
|
assert(res == VarintStatus.Success)
|
||||||
pb.offset = pos
|
pb.offset = pos
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue