1
0

Separate db from storage

- storage is content-agnostic
 - db and storage are passed to wallet contructor
This commit is contained in:
ThomasV
2020-02-05 15:13:37 +01:00
parent c61e5db6a9
commit e1ce3aace7
25 changed files with 421 additions and 421 deletions

View File

@@ -47,6 +47,7 @@ from .util import PR_PAID, PR_EXPIRED, get_request_status
from .util import log_exceptions, ignore_exceptions
from .wallet import Wallet, Abstract_Wallet
from .storage import WalletStorage
from .wallet_db import WalletDB
from .commands import known_commands, Commands
from .simple_config import SimpleConfig
from .exchange_rate import FxThread
@@ -401,20 +402,22 @@ class Daemon(Logger):
if path in self._wallets:
wallet = self._wallets[path]
return wallet
storage = WalletStorage(path, manual_upgrades=manual_upgrades)
storage = WalletStorage(path)
if not storage.file_exists():
return
if storage.is_encrypted():
if not password:
return
storage.decrypt(password)
if storage.requires_split():
# read data, pass it to db
db = WalletDB(storage.read(), manual_upgrades=manual_upgrades)
if db.requires_split():
return
if storage.requires_upgrade():
if db.requires_upgrade():
return
if storage.get_action():
if db.get_action():
return
wallet = Wallet(storage, config=self.config)
wallet = Wallet(db, storage, config=self.config)
wallet.start_network(self.network)
self._wallets[path] = wallet
self.wallet = wallet