Use min(bitcoin block version, 2) as block version instead of fixing it at 2 so BIP34...
authorForrest Voight <forrest.voight@gmail.com>
Mon, 13 Aug 2012 21:58:11 +0000 (17:58 -0400)
committerForrest Voight <forrest.voight@gmail.com>
Tue, 14 Aug 2012 18:55:45 +0000 (14:55 -0400)
p2pool/main.py
p2pool/work.py

index cb7d081..c3cede8 100644 (file)
@@ -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),
index 8e9c6fa..b430d8b 100644 (file)
@@ -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'],