make the Verifier class usable without a wallet instance
This commit is contained in:
parent
f91dde55dd
commit
8b865983c6
2
electrum
2
electrum
@ -191,7 +191,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
interface.start()
|
interface.start()
|
||||||
WalletSynchronizer(wallet, config).start()
|
WalletSynchronizer(wallet, config).start()
|
||||||
WalletVerifier(wallet, config).start()
|
WalletVerifier(interface, config, wallet.get_tx_hashes).start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
found = config.wallet_file_exists
|
found = config.wallet_file_exists
|
||||||
|
|||||||
@ -26,27 +26,22 @@ from bitcoin import *
|
|||||||
|
|
||||||
class WalletVerifier(threading.Thread):
|
class WalletVerifier(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, wallet, config):
|
def __init__(self, interface, config, get_transactions):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
self.config = config
|
self.config = config
|
||||||
self.wallet = wallet
|
self.interface = interface
|
||||||
self.interface = self.wallet.interface
|
self.get_transactions = get_transactions
|
||||||
self.interface.register_channel('verifier')
|
self.interface.register_channel('verifier')
|
||||||
self.verified_tx = config.get('verified_tx',[])
|
self.verified_tx = config.get('verified_tx',[])
|
||||||
self.merkle_roots = config.get('merkle_roots',{}) # hashed by me
|
self.merkle_roots = config.get('merkle_roots',{}) # hashed by me
|
||||||
self.targets = config.get('targets',{}) # compute targets
|
self.targets = config.get('targets',{}) # compute targets
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
self.pending_headers = [] # headers that have not been verified
|
self.pending_headers = [] # headers that have not been verified
|
||||||
|
|
||||||
self.height = 0
|
self.height = 0
|
||||||
self.local_height = 0
|
self.local_height = 0
|
||||||
self.set_local_numblocks()
|
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)
|
requested_headers.append(i)
|
||||||
|
|
||||||
# request missing tx merkle
|
# request missing tx merkle
|
||||||
txlist = self.wallet.get_tx_hashes()
|
txlist = self.get_transactions()
|
||||||
for tx in txlist:
|
for tx in txlist:
|
||||||
if tx not in self.verified_tx:
|
if tx not in self.verified_tx:
|
||||||
if tx not in requested_merkle:
|
if tx not in requested_merkle:
|
||||||
requested_merkle.append(tx)
|
requested_merkle.append(tx)
|
||||||
self.request_merkle(tx)
|
self.request_merkle(tx)
|
||||||
break
|
#break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = self.interface.get_response('verifier',timeout=1)
|
r = self.interface.get_response('verifier',timeout=1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user