else:
return bitcoind.rpc_getmemorypool()
try:
+ start = time.time()
work = yield go()
+ end = time.time()
except jsonrpc.Error_for_code(-32601): # Method not found
use_getblocktemplate = not use_getblocktemplate
try:
+ start = time.time()
work = yield go()
+ end = time.time()
except jsonrpc.Error_for_code(-32601): # Method not found
print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!'
raise deferral.RetrySilentlyException()
previous_block=int(work['previousblockhash'], 16),
transactions=map(bitcoin_data.tx_type.unpack, packed_transactions),
transaction_hashes=map(bitcoin_data.hash256, packed_transactions),
+ 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'],
bits=bitcoin_data.FloatingIntegerType().unpack(work['bits'].decode('hex')[::-1]) if isinstance(work['bits'], (str, unicode)) else bitcoin_data.FloatingInteger(work['bits']),
height=work['height'],
last_update=time.time(),
use_getblocktemplate=use_getblocktemplate,
+ latency=end - start,
))
@deferral.retry('Error submitting primary block: (will retry)', 10, 10)
@defer.inlineCallbacks
def submit_block_rpc(block, ignore_failure, bitcoind, bitcoind_work, net):
if bitcoind_work.value['use_getblocktemplate']:
- result = yield bitcoind.rpc_submitblock(bitcoin_data.block_type.pack(block).encode('hex'))
- success = result is None
+ if 'lite' in self.node.net.NAME:
+ result = yield bitcoind.rpc_getblocktemplate(dict(mode='submit', data=bitcoin_data.block_type.pack(block).encode('hex')))
+ success = result is None
+ else:
+ result = yield bitcoind.rpc_submitblock(bitcoin_data.block_type.pack(block).encode('hex'))
+ success = result is None
else:
result = yield bitcoind.rpc_getmemorypool(bitcoin_data.block_type.pack(block).encode('hex'))
success = result