my_shares = set()
times = {}
- def got_response(data):
+ def got_response(data, user):
try:
# match up with transactions
header = bitcoin.getwork.decode_data(data)
return False
share = p2pool.Share.from_block(block)
my_shares.add(share.hash)
- print 'GOT SHARE! %s prev %s age %.2fs' % (p2pool.format_hash(share.hash), p2pool.format_hash(share.previous_hash), time.time() - times[share.nonce]) + (' DEAD ON ARRIVAL' if share.previous_hash != current_work.value['best_share_hash'] else '')
+ print 'GOT SHARE! %s %s prev %s age %.2fs' % (user, p2pool.format_hash(share.hash), p2pool.format_hash(share.previous_hash), time.time() - times[share.nonce]) + (' DEAD ON ARRIVAL' if share.previous_hash != current_work.value['best_share_hash'] else '')
good = share.previous_hash == current_work.value['best_share_hash']
# maybe revert back to tracker being non-blocking so 'good' can be more accurate?
p2p_shares([share])
from p2pool.util import jsonrpc, deferred_resource, variable
from p2pool.bitcoin import data as bitcoin_data
+def get_username(request):
+ try:
+ return base64.b64decode(request.getHeader('Authorization').split(' ', 1)[1]).split(':')[0]
+ except: # XXX
+ return None
+
def get_payout_script(request, net):
+ user = get_username(request)
+ if user is None:
+ return None
try:
- user = base64.b64decode(request.getHeader('Authorization').split(' ', 1)[1]).split(':')[0]
return bitcoin_data.pubkey_hash_to_script2(bitcoin_data.address_to_pubkey_hash(user, net))
except: # XXX blah
return None
request.setHeader('X-Long-Polling', '/long-polling')
if data is not None:
- defer.returnValue(self.response_callback(data))
+ defer.returnValue(self.response_callback(data, get_username(request)))
defer.returnValue((yield self.getwork(request)))
rpc_getwork.takes_request = True