|
@ -55,12 +55,12 @@ class TxFeesValue(NamedTuple): |
|
|
|
|
|
|
|
|
class JsonDB(Logger): |
|
|
class JsonDB(Logger): |
|
|
|
|
|
|
|
|
def __init__(self, raw, *, manual_upgrades): |
|
|
def __init__(self, raw, *, manual_upgrades: bool): |
|
|
Logger.__init__(self) |
|
|
Logger.__init__(self) |
|
|
self.lock = threading.RLock() |
|
|
self.lock = threading.RLock() |
|
|
self.data = {} |
|
|
self.data = {} |
|
|
self._modified = False |
|
|
self._modified = False |
|
|
self.manual_upgrades = manual_upgrades |
|
|
self._manual_upgrades = manual_upgrades |
|
|
self._called_after_upgrade_tasks = False |
|
|
self._called_after_upgrade_tasks = False |
|
|
if raw: # loading existing db |
|
|
if raw: # loading existing db |
|
|
self.load_data(raw) |
|
|
self.load_data(raw) |
|
@ -142,12 +142,12 @@ class JsonDB(Logger): |
|
|
if not isinstance(self.data, dict): |
|
|
if not isinstance(self.data, dict): |
|
|
raise WalletFileException("Malformed wallet file (not dict)") |
|
|
raise WalletFileException("Malformed wallet file (not dict)") |
|
|
|
|
|
|
|
|
if not self.manual_upgrades and self.requires_split(): |
|
|
if not self._manual_upgrades and self.requires_split(): |
|
|
raise WalletFileException("This wallet has multiple accounts and must be split") |
|
|
raise WalletFileException("This wallet has multiple accounts and must be split") |
|
|
|
|
|
|
|
|
if not self.requires_upgrade(): |
|
|
if not self.requires_upgrade(): |
|
|
self._after_upgrade_tasks() |
|
|
self._after_upgrade_tasks() |
|
|
elif not self.manual_upgrades: |
|
|
elif not self._manual_upgrades: |
|
|
self.upgrade() |
|
|
self.upgrade() |
|
|
|
|
|
|
|
|
def requires_split(self): |
|
|
def requires_split(self): |
|
|