save to disk the list of verified transactions
This commit is contained in:
parent
f4b95244c3
commit
10d6db468a
|
@ -943,27 +943,36 @@ class WalletVerifier(threading.Thread):
|
||||||
def __init__(self, wallet, config):
|
def __init__(self, wallet, config):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
self.config = config
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
self.interface = self.wallet.interface
|
self.interface = self.wallet.interface
|
||||||
self.interface.register_channel('verifier')
|
self.interface.register_channel('verifier')
|
||||||
self.validated = []
|
self.validated = config.get('verified_tx',[])
|
||||||
self.merkle_roots = {}
|
self.merkle_roots = config.get('merkle_roots',{})
|
||||||
self.headers = {}
|
self.headers = config.get('block_headers',{})
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
self.saved = False
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
requested = []
|
requested = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
txlist = self.wallet.get_tx_hashes()
|
txlist = self.wallet.get_tx_hashes()
|
||||||
|
|
||||||
for tx in txlist:
|
for tx in txlist:
|
||||||
|
if tx not in self.validated:
|
||||||
if tx not in requested:
|
if tx not in requested:
|
||||||
requested.append(tx)
|
requested.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)
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
|
if len(self.validated) == len(txlist) and not self.saved:
|
||||||
|
print "verified %d transactions"%len(txlist)
|
||||||
|
self.config.set_key('verified_tx', self.validated, True)
|
||||||
|
self.saved = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 3. handle response
|
# 3. handle response
|
||||||
|
|
Loading…
Reference in New Issue