if 'height' not in work:
work['height'] = (yield bitcoind.rpc_getblock(work['previousblockhash']))['height'] + 1
defer.returnValue(dict(
+ version=work['version'],
previous_block=int(work['previousblockhash'], 16),
transactions=map(bitcoin_data.tx_type.unpack, packed_transactions),
merkle_link=bitcoin_data.calculate_merkle_link([None] + map(bitcoin_data.hash256, packed_transactions), 0),
print 'Skipping from block %x to block %x!' % (bb['previous_block'],
bitcoin_data.hash256(bitcoin_data.block_header_type.pack(bb)))
t = dict(
+ version=bb['version'],
previous_block=bitcoin_data.hash256(bitcoin_data.block_header_type.pack(bb)),
bits=bb['bits'], # not always true
coinbaseflags='',
self.new_work_event = variable.Event()
@self.current_work.transitioned.watch
def _(before, after):
- # trigger LP if previous_block/bits changed or transactions changed from nothing
- if any(before[x] != after[x] for x in ['previous_block', 'bits']) or (not before['transactions'] and after['transactions']):
+ # trigger LP if version/previous_block/bits changed or transactions changed from nothing
+ if any(before[x] != after[x] for x in ['version', 'previous_block', 'bits']) or (not before['transactions'] and after['transactions']):
self.new_work_event.happened()
self.merged_work.changed.watch(lambda _: self.new_work_event.happened())
self.best_share_var.changed.watch(lambda _: self.new_work_event.happened())
bits = self.current_work.value['bits']
previous_block = self.current_work.value['previous_block']
ba = bitcoin_getwork.BlockAttempt(
- version=2,
+ version=min(self.current_work.value['version'], 2),
previous_block=self.current_work.value['previous_block'],
merkle_root=merkle_root,
timestamp=self.current_work.value['time'],