Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def proof_of_work(header, difficulty_bits):
- #{
- # Obliczanie celu
- target = 2 ** (256-difficulty_bits)
- for nonce in xrange(max_nonce):
- #{
- hash_result = hashlib.sha256(str(header)+str(nonce)).hexdigest()
- # Sprawdzanie, czy wynik jest prawidłowy (mniejszy od celu)
- if long(hash_result, 16) < target:
- #{
- print "Powodzenie dla wartości nonce %d" % nonce
- print "Skrót to %s" % hash_result
- return (hash_result,nonce)
- #}
- #}
- print "Niepowodzenie po %d (max_nonce) próbach" % nonce
- return nonce
- #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement