Trying to support the PoW interruption
This commit is contained in:
parent
f8236d6e0a
commit
ec903c9165
|
@ -19,8 +19,13 @@ def _pow_worker(target, initial_hash, q):
|
|||
|
||||
while trial_value > target:
|
||||
nonce += 1
|
||||
trial_value = struct.unpack('>Q', hashlib.sha512(hashlib.sha512(
|
||||
struct.pack('>Q', nonce) + initial_hash).digest()).digest()[:8])[0]
|
||||
try:
|
||||
trial_value = struct.unpack('>Q', hashlib.sha512(hashlib.sha512(
|
||||
struct.pack('>Q', nonce) + initial_hash
|
||||
).digest()).digest()[:8])[0]
|
||||
except KeyboardInterrupt:
|
||||
q.put(None)
|
||||
return
|
||||
|
||||
q.put(struct.pack('>Q', nonce))
|
||||
|
||||
|
@ -36,6 +41,11 @@ def _worker(obj):
|
|||
nonce = q.get()
|
||||
p.join()
|
||||
|
||||
if nonce is None:
|
||||
if not shared.shutting_down:
|
||||
logging.warning('Got None nonce from _pow_worker!')
|
||||
return
|
||||
|
||||
logging.debug(
|
||||
'Finished doing POW, nonce: %s, time: %ss', nonce, time.time() - t)
|
||||
obj = structure.Object(
|
||||
|
|
Loading…
Reference in New Issue
Block a user