Merge pull request #1235 from kyuupichan/storage-write-once

Flush wallet storage once for a sequence of puts.
This commit is contained in:
ThomasV 2015-05-23 07:20:22 +02:00
commit 57c8577d66
1 changed files with 8 additions and 7 deletions

View File

@ -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)