From 5b8588ee90ad4dd53c3c593c64dbf000a82c69db Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 14 Mar 2015 09:20:27 +0100 Subject: [PATCH] rename spv class, use own print_error --- lib/__init__.py | 1 - lib/verifier.py | 12 ++++++------ lib/wallet.py | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/__init__.py b/lib/__init__.py index 053dd4d23..3f2e88d01 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -2,7 +2,6 @@ from version import ELECTRUM_VERSION from util import format_satoshis, print_msg, print_json, print_error, set_verbosity from wallet import WalletSynchronizer, WalletStorage from wallet import Wallet, Wallet_2of2, Wallet_2of3, Imported_Wallet -from verifier import TxVerifier from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server from interface import Interface from simple_config import SimpleConfig, get_config, set_config diff --git a/lib/verifier.py b/lib/verifier.py index dd6925081..c4fff524e 100644 --- a/lib/verifier.py +++ b/lib/verifier.py @@ -26,7 +26,7 @@ from bitcoin import * -class TxVerifier(util.DaemonThread): +class SPV(util.DaemonThread): """ Simple Payment Verification """ def __init__(self, network, storage): @@ -95,7 +95,7 @@ class TxVerifier(util.DaemonThread): continue if self.merkle_roots.get(tx_hash) is None and tx_hash not in requested_merkle: if self.network.send([ ('blockchain.transaction.get_merkle',[tx_hash, tx_height]) ], self.queue.put): - print_error('requesting merkle', tx_hash) + self.print_error('requesting merkle', tx_hash) requested_merkle.append(tx_hash) try: r = self.queue.get(timeout=0.1) @@ -105,7 +105,7 @@ class TxVerifier(util.DaemonThread): continue if r.get('error'): - print_error('Verifier received an error:', r) + self.print_error('Verifier received an error:', r) continue # 3. handle response @@ -127,7 +127,7 @@ class TxVerifier(util.DaemonThread): header = self.network.get_header(tx_height) if not header: return if header.get('merkle_root') != merkle_root: - print_error("merkle verification failed for", tx_hash) + self.print_error("merkle verification failed for", tx_hash) return # we passed all the tests @@ -135,7 +135,7 @@ class TxVerifier(util.DaemonThread): timestamp = header.get('timestamp') with self.lock: self.verified_tx[tx_hash] = (tx_height, timestamp, pos) - print_error("verified %s"%tx_hash) + self.print_error("verified %s"%tx_hash) self.storage.put('verified_tx3', self.verified_tx, True) self.network.trigger_callback('updated') @@ -155,7 +155,7 @@ class TxVerifier(util.DaemonThread): for tx_hash, item in items: tx_height, timestamp, pos = item if tx_height >= height: - print_error("redoing", tx_hash) + self.print_error("redoing", tx_hash) with self.lock: self.verified_tx.pop(tx_hash) if tx_hash in self.merkle_roots: diff --git a/lib/wallet.py b/lib/wallet.py index 278d4e4a2..997ccdf1e 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -948,10 +948,10 @@ class Abstract_Wallet(object): return True def start_threads(self, network): - from verifier import TxVerifier + from verifier import SPV self.network = network if self.network is not None: - self.verifier = TxVerifier(self.network, self.storage) + self.verifier = SPV(self.network, self.storage) self.verifier.start() self.set_verifier(self.verifier) self.synchronizer = WalletSynchronizer(self, network)