Browse Source

do not store merkle root before verification succeeded. keep it in requested_merkle for the session

283
ThomasV 11 years ago
parent
commit
247f4944a6
  1. 8
      lib/verifier.py

8
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)

Loading…
Cancel
Save