Proper fix for #18.

This commit is contained in:
cheatfate 2019-06-13 12:05:03 +03:00
parent d685147c52
commit 774f5c8232
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ proc getUVarint*[T: PB|LP](vtype: typedesc[T],
## byte will be decoded, all other bits will be ignored. When decoding 5th ## byte will be decoded, all other bits will be ignored. When decoding 5th
## byte of 32bit integer only 4 bits from byte will be decoded, all other bits ## byte of 32bit integer only 4 bits from byte will be decoded, all other bits
## will be ignored. ## will be ignored.
## ##
## LibP2P ## LibP2P
## When decoding 5th byte of 32bit integer only 4 bits from byte will be ## When decoding 5th byte of 32bit integer only 4 bits from byte will be
## decoded, all other bits will be ignored. ## decoded, all other bits will be ignored.
@ -115,7 +115,7 @@ proc putUVarint*[T: PB|LP](vtype: typedesc[T],
## Google ProtoBuf ## Google ProtoBuf
## Maximum encoded length of 64bit integer is 10 octets. ## Maximum encoded length of 64bit integer is 10 octets.
## Maximum encoded length of 32bit integer is 5 octets. ## Maximum encoded length of 32bit integer is 5 octets.
## ##
## LibP2P ## LibP2P
## Maximum encoded length of 63bit integer is 9 octets. ## Maximum encoded length of 63bit integer is 9 octets.
## Maximum encoded length of 32bit integer is 5 octets. ## Maximum encoded length of 32bit integer is 5 octets.
@ -214,10 +214,10 @@ proc encodeVarint*(vtype: typedesc[PB],
result.setLen(5) result.setLen(5)
else: else:
result.setLen(10) result.setLen(10)
when type(value) is SomeSVarint: when type(value) is PBSomeSVarint:
let res = putSVarint(result, outsize, value) let res = putSVarint(result, outsize, value)
else: else:
let res = putUVarint(result, outsize, value) let res = PB.putUVarint(result, outsize, value)
if res == VarintStatus.Success: if res == VarintStatus.Success:
result.setLen(outsize) result.setLen(outsize)
else: else: