1
0

walletdb: rm some dead code

This commit is contained in:
SomberNight
2024-01-23 02:20:01 +00:00
parent bb226e653e
commit cbece71894
3 changed files with 12 additions and 11 deletions

View File

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

View File

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

View File

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