do not save wallet if gap did not change, also dont encrypt on save if already encrypted

This commit is contained in:
Lex Berezhny 2019-10-18 13:12:09 -04:00
parent c448531551
commit d50ebcf9eb
2 changed files with 12 additions and 4 deletions

View file

@ -69,9 +69,17 @@ class Account(BaseAccount):
async def save_max_gap(self):
if issubclass(self.address_generator, HierarchicalDeterministic):
gap = await self.get_max_gap()
self.receiving.gap = max(20, gap['max_receiving_gap'] + 1)
self.change.gap = max(6, gap['max_change_gap'] + 1)
self.wallet.save()
gap_changed = False
new_receiving_gap = max(20, gap['max_receiving_gap'] + 1)
if self.receiving.gap != new_receiving_gap:
self.receiving.gap = new_receiving_gap
gap_changed = True
new_change_gap = max(6, gap['max_change_gap'] + 1)
if self.change.gap != new_change_gap:
self.change.gap = new_change_gap
gap_changed = True
if gap_changed:
self.wallet.save()
def get_balance(self, confirmations=0, include_claims=False, **constraints):
if not include_claims:

View file

@ -141,7 +141,7 @@ class Wallet:
}
def save(self):
if self.preferences.get(ENCRYPT_ON_DISK, False):
if not self.is_locked and self.preferences.get(ENCRYPT_ON_DISK, False):
if self.encryption_password:
self.storage.write(self.to_dict(encrypt_password=self.encryption_password))
return