def hash(hash_data): input = str(random.random()) + str(hash_data['last_block_hash']) n = hashlib.sha256(input).hexdigest() if compare_hashes(n, hash_data['best_hash']): hash_data['best_hash'] = n print "hash found "+str(n) print util.hash_to_int(n) hash_data['hash_answer'] = input return hash_data
def compare_hashes(new_hash, best_hash): return util.hash_to_int(new_hash) < util.hash_to_int(best_hash)