From f6874ee268e55f8609b0b7df2fb3fafa68348590 Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Mon, 13 Aug 2012 17:58:11 -0400 Subject: [PATCH] Use min(bitcoin block version, 2) as block version instead of fixing it at 2 so BIP34 voting process isn't messed up --- p2pool/main.py | 1 + p2pool/work.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/p2pool/main.py b/p2pool/main.py index cb7d081..c3cede8 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -40,6 +40,7 @@ def getwork(bitcoind): 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), diff --git a/p2pool/work.py b/p2pool/work.py index 8e9c6fa..b430d8b 100644 --- a/p2pool/work.py +++ b/p2pool/work.py @@ -85,6 +85,7 @@ class WorkerBridge(worker_interface.WorkerBridge): 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='', @@ -105,8 +106,8 @@ class WorkerBridge(worker_interface.WorkerBridge): 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()) @@ -240,7 +241,7 @@ class WorkerBridge(worker_interface.WorkerBridge): 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'], -- 1.7.1