try:
# match up with transactions
header = bitcoin.getwork.decode_data(data)
- transactions = merkle_root_to_transactions.get(header['merkle_root'], None)
- if transactions is None:
+ xxx = merkle_root_to_transactions.get(header['merkle_root'], None)
+ if xxx is None:
print '''Couldn't link returned work's merkle root with its transactions - should only happen if you recently restarted p2pool'''
return False
- block = dict(header=header, txs=transactions)
- hash_ = bitcoin.data.block_header_type.hash256(block['header'])
+ is_new, share_info, transactions = xxx
+ new_share_info = share_info
+
+ hash_ = bitcoin.data.block_header_type.hash256(header)
+
- pow = bitcoin.data.block_header_type.scrypt(header) if getattr(args.net, 'BITCOIN_POW_SCRYPT', False) else hash_
+ pow_hash = args.net.BITCOIN_POW_FUNC(block['header'])
- if pow <= header['target'] or p2pool_init.DEBUG:
- if pow_hash <= block['header']['target'] or p2pool_init.DEBUG:
++ if pow_hash <= header['target'] or p2pool_init.DEBUG:
if factory.conn.value is not None:
- factory.conn.value.send_block(block=block)
+ factory.conn.value.send_block(block=dict(header=header, txs=transactions))
else:
print 'No bitcoind connection! Erp!'
- if pow <= header['target']:
- if pow_hash <= block['header']['target']:
++ if pow_hash <= header['target']:
print
print 'GOT BLOCK! Passing to bitcoind! bitcoin: %x' % (hash_,)
print
except:
log.err(None, 'Error while processing merged mining POW:')
- target = p2pool.coinbase_type.unpack(transactions[0]['tx_ins'][0]['script'])['share_data']['target']
+ target = new_share_info['target']
- if pow > target:
- print 'Worker submitted share with hash > target:\nhash : %x\ntarget: %x' % (pow, target)
+ if pow_hash > target:
+ print 'Worker submitted share with hash > target:\nhash : %x\ntarget: %x' % (pow_hash, target)
return False
- share = p2pool.Share.from_block(block, args.net)
+ if is_new:
+ share = p2pool.NewShare(args.net, header, new_share_info, other_txs=transactions[1:])
+ else:
+ share = p2pool.Share(args.net, header, share_info, other_txs=transactions[1:])
my_shares.add(share.hash)
if share.previous_hash != current_work.value['best_share_hash']:
doa_shares.add(share.hash)