Made changes suggested by nimdahk
This commit is contained in:
parent
f6a07a374a
commit
f3e8ce3b82
|
@ -107,12 +107,7 @@ def encodeAddress(version,stream,ripe):
|
||||||
elif version == 4:
|
elif version == 4:
|
||||||
if len(ripe) != 20:
|
if len(ripe) != 20:
|
||||||
raise Exception("Programming error in encodeAddress: The length of a given ripe hash was not 20.")
|
raise Exception("Programming error in encodeAddress: The length of a given ripe hash was not 20.")
|
||||||
emptybitcounter = 0
|
ripe = ripe.lstrip('\x00')
|
||||||
while True:
|
|
||||||
if ripe[emptybitcounter] != '\x00':
|
|
||||||
break
|
|
||||||
emptybitcounter += 1
|
|
||||||
ripe = ripe[emptybitcounter:]
|
|
||||||
|
|
||||||
a = encodeVarint(version) + encodeVarint(stream) + ripe
|
a = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||||
sha = hashlib.new('sha512')
|
sha = hashlib.new('sha512')
|
||||||
|
@ -207,9 +202,7 @@ def decodeAddress(address):
|
||||||
elif len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]) < 4:
|
elif len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]) < 4:
|
||||||
return 'ripetooshort',0,0,0
|
return 'ripetooshort',0,0,0
|
||||||
else:
|
else:
|
||||||
x00string = ''
|
x00string = '\x00' * (20 - len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]))
|
||||||
for i in range(20 - len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4])):
|
|
||||||
x00string += '\x00'
|
|
||||||
return status,addressVersionNumber,streamNumber,x00string+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
|
return status,addressVersionNumber,streamNumber,x00string+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user