changing wallet initialization order

This commit is contained in:
Kay Kurokawa 2016-12-19 15:24:14 -05:00
parent 7404b127bf
commit 7d02e7d370

View file

@ -809,9 +809,11 @@ class LBRYumWallet(Wallet):
self._start_check = task.LoopingCall(check_started) self._start_check = task.LoopingCall(check_started)
d.addCallback(lambda _: self._load_wallet())
d.addCallback(self._save_wallet)
d.addCallback(lambda _: self._start_check.start(.1)) d.addCallback(lambda _: self._start_check.start(.1))
d.addCallback(lambda _: network_start_d) d.addCallback(lambda _: network_start_d)
d.addCallback(lambda _: self._load_wallet()) d.addCallback(lambda _: self._load_blockchain())
d.addCallback(lambda _: self._get_cmd_runner()) d.addCallback(lambda _: self._get_cmd_runner())
return d return d
@ -843,8 +845,6 @@ class LBRYumWallet(Wallet):
return d return d
def _load_wallet(self): def _load_wallet(self):
def get_wallet():
path = self.config.get_wallet_path() path = self.config.get_wallet_path()
storage = lbryum.wallet.WalletStorage(path) storage = lbryum.wallet.WalletStorage(path)
wallet = lbryum.wallet.Wallet(storage) wallet = lbryum.wallet.Wallet(storage)
@ -858,6 +858,7 @@ class LBRYumWallet(Wallet):
self.wallet = wallet self.wallet = wallet
return defer.succeed(True) return defer.succeed(True)
def _load_blockchain(self):
blockchain_caught_d = defer.Deferred() blockchain_caught_d = defer.Deferred()
def check_caught_up(): def check_caught_up():
@ -900,9 +901,7 @@ class LBRYumWallet(Wallet):
return defer.fail(err) return defer.fail(err)
self._catch_up_check = task.LoopingCall(check_caught_up) self._catch_up_check = task.LoopingCall(check_caught_up)
d = get_wallet() d = defer.succeed(self.wallet.start_threads(self.network))
d.addCallback(self._save_wallet)
d.addCallback(lambda _: self.wallet.start_threads(self.network))
d.addCallback(lambda _: self._catch_up_check.start(.1)) d.addCallback(lambda _: self._catch_up_check.start(.1))
d.addErrback(log_error) d.addErrback(log_error)
d.addCallback(lambda _: blockchain_caught_d) d.addCallback(lambda _: blockchain_caught_d)