addresses: raise varintEncodeError in encodeVarint()

instead of SystemExit (looks like a bug)
v0.6
Dmitri Bogomolov 3 years ago
parent 7a1f803c92
commit 0967f03b40
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

@ -54,11 +54,20 @@ def decodeBase58(string, alphabet=ALPHABET):
return num
class varintEncodeError(Exception):
"""Exception class for encoding varint"""
pass
class varintDecodeError(Exception):
"""Exception class for decoding varint data"""
pass
def encodeVarint(integer):
"""Convert integer into varint bytes"""
if integer < 0:
logger.error('varint cannot be < 0')
raise SystemExit
raise varintEncodeError('varint cannot be < 0')
if integer < 253:
return pack('>B', integer)
if integer >= 253 and integer < 65536:
@ -68,13 +77,7 @@ def encodeVarint(integer):
if integer >= 4294967296 and integer < 18446744073709551616:
return pack('>B', 255) + pack('>Q', integer)
if integer >= 18446744073709551616:
logger.error('varint cannot be >= 18446744073709551616')
raise SystemExit
class varintDecodeError(Exception):
"""Exception class for decoding varint data"""
pass
raise varintEncodeError('varint cannot be >= 18446744073709551616')
def decodeVarint(data):

Loading…
Cancel
Save