From cbece71894580c0739767e200cd0b3d7ba9e58ea Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 23 Jan 2024 02:20:01 +0000 Subject: [PATCH] walletdb: rm some dead code --- electrum/json_db.py | 3 +-- electrum/wallet.py | 4 ---- electrum/wallet_db.py | 16 +++++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/electrum/json_db.py b/electrum/json_db.py index 1c1841bd8..c30e6d9b4 100644 --- a/electrum/json_db.py +++ b/electrum/json_db.py @@ -228,8 +228,7 @@ class JsonDB(Logger): if self.storage and self.storage.file_exists(): self.write_and_force_consolidation() - def load_data(self, s:str) -> dict: - """ overloaded in wallet_db """ + def load_data(self, s: str) -> dict: if s == '': return {} try: diff --git a/electrum/wallet.py b/electrum/wallet.py index 83069d196..b93cdc983 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -388,10 +388,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): network: Optional['Network'] def __init__(self, db: WalletDB, *, config: SimpleConfig): - - #if not db.is_ready_to_be_used_by_wallet(): - # raise Exception("storage not ready to be used by Abstract_Wallet") - self.config = config assert self.config is not None, "config must not be None" self.db = db diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index f22cf4e66..359266eca 100644 --- a/electrum/wallet_db.py +++ b/electrum/wallet_db.py @@ -49,6 +49,9 @@ from .json_db import StoredDict, JsonDB, locked, modifier, StoredObject, stored_ from .plugin import run_hook, plugin_loaders from .version import ELECTRUM_VERSION +if TYPE_CHECKING: + from .storage import WalletStorage + class WalletRequiresUpgrade(WalletFileException): pass @@ -1204,7 +1207,7 @@ class WalletDBUpgrader(Logger): raise WalletFileException(msg) -def upgrade_wallet_db(data: dict, do_upgrade) -> Tuple[dict, bool]: +def upgrade_wallet_db(data: dict, do_upgrade: bool) -> Tuple[dict, bool]: was_upgraded = False if len(data) == 0: @@ -1232,7 +1235,13 @@ def upgrade_wallet_db(data: dict, do_upgrade) -> Tuple[dict, bool]: class WalletDB(JsonDB): - def __init__(self, s, *, storage=None, upgrade=False): + def __init__( + self, + s: str, + *, + storage: Optional['WalletStorage'] = None, + upgrade: bool = False, + ): JsonDB.__init__(self, s, storage, encoder=MyEncoder, upgrader=partial(upgrade_wallet_db, do_upgrade=upgrade)) # create pointers self.load_transactions() @@ -1649,9 +1658,6 @@ class WalletDB(JsonDB): return False return True - def is_ready_to_be_used_by_wallet(self): - return not self._requires_upgrade - @classmethod def split_accounts(klass, root_path, split_data): from .storage import WalletStorage