From 69b8ec46346adb6e23b63c75bfdf18e834427884 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 14 May 2012 15:56:15 +0000 Subject: [PATCH] Use BIP22 "obj" transactions when possible Backward compatibility with hex-only and gmp_fees retained for now --- merklemaker.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/merklemaker.py b/merklemaker.py index c9e491c..5bb6392 100644 --- a/merklemaker.py +++ b/merklemaker.py @@ -42,7 +42,7 @@ class merkleMaker(threading.Thread): 'transactions/remove', 'prevblock', ], - 'tx': 'hex', + 'tx': 'obj', } def __init__(self, *a, **k): @@ -131,8 +131,21 @@ class merkleMaker(threading.Thread): bits = bytes.fromhex(MP['bits'])[::-1] if (prevBlock, bits) != self.currentBlock: self.updateBlock(prevBlock, bits, _HBH=(MP['previousblockhash'], MP['bits'])) + + txnlist = MP['transactions'] + if len(txnlist) and isinstance(txnlist[0], dict): + txninfo = txnlist + txnlist = tuple(a['data'] for a in txnlist) + txninfo.insert(0, { + }) + elif 'transactionfees' in MP: + # Backward compatibility with pre-BIP22 gmp_fees branch + txninfo = [{'fee':a} for a in MP['transactionfees']] + else: + # Backward compatibility with pre-BIP22 hex-only (bitcoind <0.7, Eloipool txncount: - feeinfoLen = txncount - elif feeinfoLen < txncount: - idealtxncount -= txncount - feeinfoLen - for i in range(feeinfoLen - 1, 0, -1): - if feeinfo[i]: + for i in range(len(txninfo) - 1, 0, -1): + if 'fee' not in txninfo[i] or txninfo[i]['fee']: break idealtxncount -= 1 -- 2.1.4