added start/step support to work() to support multithreading
This commit is contained in:
parent
027b1e20fb
commit
d3a3a4bb6b
@ -18,8 +18,8 @@ class pow_base:
|
|||||||
self._base = urandom(self._bits//8) if not base else base
|
self._base = urandom(self._bits//8) if not base else base
|
||||||
self._target = 2 ** (self._bits - difficulty)
|
self._target = 2 ** (self._bits - difficulty)
|
||||||
|
|
||||||
def work(self, max_attempts=0):
|
def work(self, max_attempts=0, start=0, step=1):
|
||||||
cycles = count() if max_attempts == 0 else range(max_attempts)
|
cycles = count(start, step) if max_attempts == 0 else range(start, max_attempts, step)
|
||||||
for nonce in cycles:
|
for nonce in cycles:
|
||||||
if self.verify(nonce):
|
if self.verify(nonce):
|
||||||
return nonce
|
return nonce
|
||||||
|
Loading…
Reference in New Issue
Block a user