Browse Source

rename spv class, use own print_error

283
ThomasV 10 years ago
parent
commit
5b8588ee90
  1. 1
      lib/__init__.py
  2. 12
      lib/verifier.py
  3. 4
      lib/wallet.py

1
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

12
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:

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

Loading…
Cancel
Save