Skip to content

Commit

Permalink
Dirty fix for queue support like phoenix's -q 3. see (self.workQueue.…
Browse files Browse the repository at this point in the history
…qsize() <= 2) in mine().
  • Loading branch information
techwtf committed Jul 1, 2011
1 parent dbfb891 commit 789ad31
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions BitcoinMiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def mine(self):
if self.stop: return
try:
with self.lock:
update = self.update = (self.update or time() - self.lastWork > if_else(self.longPollActive, LONG_POLL_MAX_ASKRATE, self.askrate))
update = self.update = (self.update or (self.workQueue.qsize() <= 2) or time() - self.lastWork > if_else(self.longPollActive, LONG_POLL_MAX_ASKRATE, self.askrate))
if update:
work = self.getwork()
with self.lock:
Expand Down Expand Up @@ -354,7 +354,7 @@ def miningThread(self):
while True:
sleep(self.frameSleep)
if self.stop: return
if (not work) or (not self.workQueue.empty()):
if not work:
try:
work = self.workQueue.get(True, 1)
except Empty: continue
Expand All @@ -367,6 +367,9 @@ def miningThread(self):
target = np.array(unpack('IIIIIIII', work['target'].decode('hex')), dtype=np.uint32)
state2 = partial(state, data, f)
calculateF(state, data, f, state2)
if self.lastBlock != work['data'][48:56]:
work = None
continue

self.miner.search( queue, (globalThreads, ), (self.worksize, ),
state[0], state[1], state[2], state[3], state[4], state[5], state[6], state[7],
Expand Down Expand Up @@ -413,7 +416,7 @@ def miningThread(self):
self.update = True
noncesLeft += 0xFFFFFFFFFFFF
elif 0xFFFFFFFFFFF < noncesLeft < 0xFFFFFFFFFFFF:
self.sayLine('warning: job finished, miner is idle')
if self.workQueue.empty(): self.sayLine('warning: job finished, miner is idle')
work = None
elif now - lastNTime > 1:
data[1] = bytereverse(bytereverse(data[1]) + 1)
Expand Down

0 comments on commit 789ad31

Please sign in to comment.