X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fbitcoin%2Fhelper.py;fp=p2pool%2Fbitcoin%2Fhelper.py;h=16cb6d5576cc76eb9282a30c3dadff1a07164ef2;hb=454013d9d67629e444944c6bed91abfb1c61c6c3;hp=d4fb288707f743ebcf356fe1443c179f056f32c4;hpb=d66ad5d6f8c934b8c9d3f1d31e7452c0916446ef;p=p2pool.git diff --git a/p2pool/bitcoin/helper.py b/p2pool/bitcoin/helper.py index d4fb288..16cb6d5 100644 --- a/p2pool/bitcoin/helper.py +++ b/p2pool/bitcoin/helper.py @@ -39,6 +39,16 @@ def getwork(bitcoind, use_getblocktemplate=False): print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!' raise deferral.RetrySilentlyException() packed_transactions = [(x['data'] if isinstance(x, dict) else x).decode('hex') for x in work['transactions']] + + transactions=map(bitcoin_data.tx_type.unpack, packed_transactions) + transaction_hashes=map(bitcoin_data.hash256, packed_transactions) + + txn_timestamp = 0 + + for tx in transactions: + if tx.timestamp > txn_timestamp: + txn_timestamp = tx.timestamp + if 'height' not in work: work['height'] = (yield bitcoind.rpc_getblock(work['previousblockhash']))['height'] + 1 elif p2pool.DEBUG: @@ -46,11 +56,12 @@ def getwork(bitcoind, use_getblocktemplate=False): defer.returnValue(dict( version=work['version'], previous_block=int(work['previousblockhash'], 16), - transactions=map(bitcoin_data.tx_type.unpack, packed_transactions), - transaction_hashes=map(bitcoin_data.hash256, packed_transactions), + transactions=transactions, + transaction_hashes=transaction_hashes, transaction_fees=[x.get('fee', None) if isinstance(x, dict) else None for x in work['transactions']], subsidy=work['coinbasevalue'], time=work['time'] if 'time' in work else work['curtime'], + txn_timestamp=txn_timestamp, bits=bitcoin_data.FloatingIntegerType().unpack(work['bits'].decode('hex')[::-1]) if isinstance(work['bits'], (str, unicode)) else bitcoin_data.FloatingInteger(work['bits']), coinbaseflags=work['coinbaseflags'].decode('hex') if 'coinbaseflags' in work else ''.join(x.decode('hex') for x in work['coinbaseaux'].itervalues()) if 'coinbaseaux' in work else '', height=work['height'],