Browse Source

make the Verifier class usable without a wallet instance

283
thomasv 12 years ago
parent
commit
8b865983c6
  1. 2
      electrum
  2. 15
      lib/verifier.py

2
electrum

@ -191,7 +191,7 @@ if __name__ == '__main__':
interface.start()
WalletSynchronizer(wallet, config).start()
WalletVerifier(wallet, config).start()
WalletVerifier(interface, config, wallet.get_tx_hashes).start()
try:
found = config.wallet_file_exists

15
lib/verifier.py

@ -26,27 +26,22 @@ from bitcoin import *
class WalletVerifier(threading.Thread):
def __init__(self, wallet, config):
def __init__(self, interface, config, get_transactions):
threading.Thread.__init__(self)
self.daemon = True
self.config = config
self.wallet = wallet
self.interface = self.wallet.interface
self.interface = interface
self.get_transactions = get_transactions
self.interface.register_channel('verifier')
self.verified_tx = config.get('verified_tx',[])
self.merkle_roots = config.get('merkle_roots',{}) # hashed by me
self.targets = config.get('targets',{}) # compute targets
self.lock = threading.Lock()
self.pending_headers = [] # headers that have not been verified
self.height = 0
self.local_height = 0
self.set_local_numblocks()
#prev_header = self.read_header(0)
#print prev_header
#sys.exit()
@ -79,13 +74,13 @@ class WalletVerifier(threading.Thread):
requested_headers.append(i)
# request missing tx merkle
txlist = self.wallet.get_tx_hashes()
txlist = self.get_transactions()
for tx in txlist:
if tx not in self.verified_tx:
if tx not in requested_merkle:
requested_merkle.append(tx)
self.request_merkle(tx)
break
#break
try:
r = self.interface.get_response('verifier',timeout=1)

Loading…
Cancel
Save