added start/step support to work() to support multithreading

This commit is contained in:
Kjistóf 2017-12-03 13:44:04 +01:00
parent 027b1e20fb
commit d3a3a4bb6b
1 changed files with 2 additions and 2 deletions

View File

@ -18,8 +18,8 @@ class pow_base:
self._base = urandom(self._bits//8) if not base else base
self._target = 2 ** (self._bits - difficulty)
def work(self, max_attempts=0):
cycles = count() if max_attempts == 0 else range(max_attempts)
def work(self, max_attempts=0, start=0, step=1):
cycles = count(start, step) if max_attempts == 0 else range(start, max_attempts, step)
for nonce in cycles:
if self.verify(nonce):
return nonce