Make the synchronizer not a thread.
The synchronizer's work is done from the network proxy's main loop. A minor problem with the old synchronizer was that it considered itself out of date if the network was out of date. This was too generic: the network can have pending requests unrelated to the synchronizer. This resulted in the synchronizer often unnecessarily flipping the wallet between up-to-date and not-up-to-date, and causing unnecessary calls to wallet.save_transactions(). This was observable when opening the network dialog box: frequently just opening it would cause a wallet status change and transaction flush, simply because the network dialog sends a get_parameters() request. This rework of the synchronizer does not have that issue.
This commit is contained in:
@@ -1105,15 +1105,16 @@ class Abstract_Wallet(object):
|
||||
self.verifier.start()
|
||||
self.set_verifier(self.verifier)
|
||||
self.synchronizer = WalletSynchronizer(self, network)
|
||||
self.synchronizer.start()
|
||||
network.jobs.append(self.synchronizer.main_loop)
|
||||
else:
|
||||
self.verifier = None
|
||||
self.synchronizer =None
|
||||
self.synchronizer = None
|
||||
|
||||
def stop_threads(self):
|
||||
if self.network:
|
||||
self.verifier.stop()
|
||||
self.synchronizer.stop()
|
||||
self.network.jobs = []
|
||||
self.synchronizer = None
|
||||
self.storage.put('stored_height', self.get_local_height(), True)
|
||||
|
||||
def restore(self, cb):
|
||||
|
||||
Reference in New Issue
Block a user