Shorten hashMeetsDifficulty function

master
0Gitnick 2019-08-13 15:18:43 -05:00
parent 401723f5ab
commit 6c091acd34
1 changed files with 5 additions and 6 deletions

View File

@ -63,19 +63,18 @@ def getHashDifficulty(hexHash):
return difficulty return difficulty
def hashMeetsDifficulty(h): def hashMeetsDifficulty(hexHash):
''' '''
Return bool for a hash string to see if it meets pow difficulty defined in config Return bool for a hash string to see if it meets pow difficulty defined in config
''' '''
hashDifficulty = getHashDifficulty(h) hashDifficulty = getHashDifficulty(hexHash)
try: try:
expected = int(config.get('general.minimum_block_pow')) expected = int(config.get('general.minimum_block_pow'))
except TypeError: except TypeError:
raise ValueError('Missing general.minimum_block_pow config') raise ValueError('Missing general.minimum_block_pow config')
if hashDifficulty >= expected:
return True return hashDifficulty >= expected
else:
return False
class DataPOW: class DataPOW:
def __init__(self, data, forceDifficulty=0, threadCount = 1): def __init__(self, data, forceDifficulty=0, threadCount = 1):