From 9455815ad0089486bcd3ceef447b7cc704190f47 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 26 Aug 2015 17:12:40 +0900 Subject: [PATCH] Merge requested_merkle and merkle_roots. --- lib/verifier.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/verifier.py b/lib/verifier.py index c19a02b74..558e1d977 100644 --- a/lib/verifier.py +++ b/lib/verifier.py @@ -28,18 +28,19 @@ class SPV(ThreadJob): def __init__(self, network, wallet): self.wallet = wallet self.network = network - self.merkle_roots = {} # hashed by me - self.requested_merkle = set() + # Keyed by tx hash. Value is None if the merkle branch was + # requested, and the merkle root once it has been verified + self.merkle_roots = {} def run(self): unverified = self.wallet.get_unverified_txs() for (tx_hash, tx_height) in unverified: - if tx_hash not in self.merkle_roots and tx_hash not in self.requested_merkle: + if tx_hash not in self.merkle_roots: request = ('blockchain.transaction.get_merkle', [tx_hash, tx_height]) if self.network.send([request], self.merkle_response): self.print_error('requested merkle', tx_hash) - self.requested_merkle.add(tx_hash) + self.merkle_roots[tx_hash] = None def merkle_response(self, r): if r.get('error'):