From 77490e47649777ee9a11a36d5fb9617dad0eddeb Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 23 May 2015 10:52:10 +0900 Subject: [PATCH] Flush wallet storage once for a sequence of puts. This speeds up save_transactions by 2 to 3 times for me. --- lib/wallet.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/wallet.py b/lib/wallet.py index 9a7e974a..803c2a83 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -202,10 +202,11 @@ class Abstract_Wallet(object): tx = {} for k,v in self.transactions.items(): tx[k] = str(v) - self.storage.put('transactions', tx) - self.storage.put('txi', self.txi) - self.storage.put('txo', self.txo) - self.storage.put('pruned_txo', self.pruned_txo) + # Flush storage only with the last put + self.storage.put('transactions', tx, False) + self.storage.put('txi', self.txi, False) + self.storage.put('txo', self.txo, False) + self.storage.put('pruned_txo', self.pruned_txo, True) def clear_history(self): with self.transaction_lock: @@ -1263,8 +1264,8 @@ class Deterministic_Wallet(Abstract_Wallet): else: self.use_encryption = False - self.storage.put('seed', self.seed, True) - self.storage.put('seed_version', self.seed_version, True) + self.storage.put('seed', self.seed, False) + self.storage.put('seed_version', self.seed_version, False) self.storage.put('use_encryption', self.use_encryption,True) def get_seed(self, password): @@ -1718,7 +1719,7 @@ class OldWallet(Deterministic_Wallet): def create_watching_only_wallet(self, mpk): self.seed_version = OLD_SEED_VERSION - self.storage.put('seed_version', self.seed_version, True) + self.storage.put('seed_version', self.seed_version, False) self.storage.put('master_public_key', mpk, True) self.create_account(mpk)