Delegate finding leading zeroes to library functions
This commit is contained in:
parent
8a36144675
commit
60c9a395f6
@ -52,17 +52,15 @@ def getDifficultyForNewBlock(data, ourBlock=True):
|
|||||||
|
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
def getHashDifficulty(h):
|
def getHashDifficulty(hexHash):
|
||||||
'''
|
'''
|
||||||
Return the amount of leading zeroes in a hex hash string (h)
|
Return the amount of leading zeroes in a hex hash string (hexHash)
|
||||||
'''
|
'''
|
||||||
difficulty = 0
|
difficulty = 0
|
||||||
assert type(h) is str
|
assert type(hexHash) is str
|
||||||
for character in h:
|
|
||||||
if character == '0':
|
difficulty = len(hexHash) - len(hexHash.lstrip('0'))
|
||||||
difficulty += 1
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
return difficulty
|
return difficulty
|
||||||
|
|
||||||
def hashMeetsDifficulty(h):
|
def hashMeetsDifficulty(h):
|
||||||
|
Loading…
Reference in New Issue
Block a user