commit 247f4944a6ed1f53ef59557b3040871ae5e2704d
parent 4f56cda0c31ac4deb170881e718735d10435cde7
Author: ThomasV <thomasv@gitorious>
Date: Fri, 15 Aug 2014 23:30:55 +0200
do not store merkle root before verification succeeded. keep it in requested_merkle for the session
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/verifier.py b/lib/verifier.py
@@ -129,22 +129,20 @@ class TxVerifier(threading.Thread):
if method == 'blockchain.transaction.get_merkle':
tx_hash = params[0]
self.verify_merkle(tx_hash, result)
- requested_merkle.remove(tx_hash)
def verify_merkle(self, tx_hash, result):
tx_height = result.get('block_height')
pos = result.get('pos')
- self.merkle_roots[tx_hash] = self.hash_merkle_root(result['merkle'], tx_hash, pos)
+ merkle_root = self.hash_merkle_root(result['merkle'], tx_hash, pos)
header = self.network.get_header(tx_height)
if not header: return
- if header.get('merkle_root') != self.merkle_roots[tx_hash]:
+ if header.get('merkle_root') != merkle_root:
print_error("merkle verification failed for", tx_hash)
- print_error(header)
- print_error(result)
return
# we passed all the tests
+ self.merkle_roots[tx_hash] = merkle_root
timestamp = header.get('timestamp')
with self.lock:
self.verified_tx[tx_hash] = (tx_height, timestamp, pos)