From e9b103b283273d7a5bae13989bbe4e55bc03372c Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 2 Sep 2013 08:50:39 +0200 Subject: [PATCH] fix regressions in tx verifier --- lib/blockchain.py | 1 - lib/verifier.py | 19 ++++++++++--------- lib/wallet.py | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/blockchain.py b/lib/blockchain.py index c84ea71ab..c48c7fb66 100644 --- a/lib/blockchain.py +++ b/lib/blockchain.py @@ -53,7 +53,6 @@ class BlockchainVerifier(threading.Thread): with self.lock: self.running = True - requested_merkle = [] requested_chunks = [] requested_headers = [] all_chunks = False diff --git a/lib/verifier.py b/lib/verifier.py index 5a86164a0..32a6842ce 100644 --- a/lib/verifier.py +++ b/lib/verifier.py @@ -96,16 +96,18 @@ class TxVerifier(threading.Thread): with self.lock: return self.running def run(self): + with self.lock: + self.running = True + requested_merkle = [] while self.is_running(): # request missing tx - if all_chunks: - for tx_hash, tx_height in self.transactions.items(): - if tx_hash not in self.verified_tx: - if self.merkle_roots.get(tx_hash) is None and tx_hash not in requested_merkle: - print_error('requesting merkle', tx_hash) - self.interface.send([ ('blockchain.transaction.get_merkle',[tx_hash, tx_height]) ], 'txverifier') - requested_merkle.append(tx_hash) + for tx_hash, tx_height in self.transactions.items(): + if tx_hash not in self.verified_tx: + if self.merkle_roots.get(tx_hash) is None and tx_hash not in requested_merkle: + print_error('requesting merkle', tx_hash) + self.interface.send([ ('blockchain.transaction.get_merkle',[tx_hash, tx_height]) ], 'txverifier') + requested_merkle.append(tx_hash) try: r = self.interface.get_response('txverifier',timeout=1) @@ -136,12 +138,11 @@ class TxVerifier(threading.Thread): if not header: return assert header.get('merkle_root') == self.merkle_roots[tx_hash] # we passed all the tests - header = self.read_header(tx_height) timestamp = header.get('timestamp') with self.lock: self.verified_tx[tx_hash] = (tx_height, timestamp, pos) print_error("verified %s"%tx_hash) - self.storage.set_key('verified_tx3', self.verified_tx, True) + self.storage.put('verified_tx3', self.verified_tx, True) self.interface.trigger_callback('updated') diff --git a/lib/wallet.py b/lib/wallet.py index 686c7425a..10f749b0a 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -1307,6 +1307,7 @@ class Wallet: self.interface = interface self.verifier = TxVerifier(interface, blockchain, self.storage) self.verifier.start() + self.set_verifier(self.verifier) self.synchronizer = WalletSynchronizer(self) self.synchronizer.start()