Skip to content

Commit

Permalink
send work right after subscribe with unknown username to work with st…
Browse files Browse the repository at this point in the history
…ratum-mining-proxy
  • Loading branch information
forrestv committed Jan 1, 2013
1 parent ca2e77d commit 2dffea0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions p2pool/bitcoin/stratum.py
Expand Up @@ -18,6 +18,8 @@ def __init__(self, wb, other):
self.watch_id = self.wb.new_work_event.watch(self._send_work)

def rpc_subscribe(self):
reactor.callLater(0, self._send_work)

return [
["mining.notify", "ae6812eb4cd7735a302a8a9dd95cf71f"], # subscription details
"", # extranonce1
Expand All @@ -30,10 +32,7 @@ def rpc_authorize(self, username, password):
reactor.callLater(0, self._send_work)

def _send_work(self):
if self.username is None: # authorize hasn't been received yet
return

x, got_response = self.wb.get_work(*self.wb.preprocess_request(self.username))
x, got_response = self.wb.get_work(*self.wb.preprocess_request('' if self.username is None else self.username))
jobid = str(random.randrange(2**128))
self.other.svc_mining.rpc_set_difficulty(bitcoin_data.target_to_difficulty(x['share_target'])).addErrback(lambda err: None)
self.other.svc_mining.rpc_notify(
Expand Down

0 comments on commit 2dffea0

Please sign in to comment.