Fix compilation error.

This commit is contained in:
cheatfate 2019-03-16 00:47:04 +02:00
parent ed3c6d1612
commit 80ec410118
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 2 additions and 5 deletions

View File

@ -56,11 +56,8 @@ proc initVBuffer*(): VBuffer =
proc writeVarint*(vb: var VBuffer, value: LPSomeUVarint) = proc writeVarint*(vb: var VBuffer, value: LPSomeUVarint) =
## Write ``value`` as variable unsigned integer. ## Write ``value`` as variable unsigned integer.
var length = 0 var length = 0
when sizeof(value) == 8: # LibP2P varint supports only 63 bits.
# LibP2P varint supports only 63 bits. var v = value and cast[type(value)](0x7FFF_FFFF_FFFF_FFFF)
var v = value and cast[type(value)](0x7FFF_FFFF_FFFF_FFFF)
else:
var v = uint64(v)
vb.buffer.setLen(len(vb.buffer) + vsizeof(v)) vb.buffer.setLen(len(vb.buffer) + vsizeof(v))
let res = LP.putUVarint(toOpenArray(vb.buffer, vb.offset, len(vb.buffer) - 1), let res = LP.putUVarint(toOpenArray(vb.buffer, vb.offset, len(vb.buffer) - 1),
length, v) length, v)