1
0

Write the wallet less often

This should speed up synchronization / restoration of large wallets.
Wallets are written only when they switch to up_to_date state, or
when stop_threads() is called when closing the daemon, or when
a command line command finishes.
This commit is contained in:
Neil Booth
2015-12-20 15:39:57 +09:00
parent 0a3d74de8f
commit e1c0298fc2
9 changed files with 57 additions and 53 deletions

View File

@@ -42,9 +42,9 @@ class LabelsPlugin(BasePlugin):
self.set_nonce(wallet, nonce)
return nonce
def set_nonce(self, wallet, nonce, force_write=True):
def set_nonce(self, wallet, nonce):
self.print_error("set", wallet.basename(), "nonce to", nonce)
wallet.storage.put("wallet_nonce", nonce, force_write)
wallet.storage.put("wallet_nonce", nonce)
@hook
def set_label(self, wallet, item, label):
@@ -61,7 +61,7 @@ class LabelsPlugin(BasePlugin):
t.setDaemon(True)
t.start()
# Caller will write the wallet
self.set_nonce(wallet, nonce + 1, force_write=False)
self.set_nonce(wallet, nonce + 1)
def do_request(self, method, url = "/labels", is_batch=False, data=None):
url = 'https://' + self.target_host + url
@@ -125,8 +125,8 @@ class LabelsPlugin(BasePlugin):
self.print_error("received %d labels" % len(response))
# do not write to disk because we're in a daemon thread
wallet.storage.put('labels', wallet.labels, False)
self.set_nonce(wallet, response["nonce"] + 1, False)
wallet.storage.put('labels', wallet.labels)
self.set_nonce(wallet, response["nonce"] + 1)
self.on_pulled(wallet)
except Exception as e:

View File

@@ -305,8 +305,8 @@ class TrustedCoinPlugin(BasePlugin):
return
password = window.password_dialog()
wallet.storage.put('seed_version', wallet.seed_version, True)
wallet.storage.put('use_encryption', password is not None, True)
wallet.storage.put('seed_version', wallet.seed_version)
wallet.storage.put('use_encryption', password is not None)
words = seed.split()
n = len(words)/2