merge updates

This commit is contained in:
Jack 2016-03-23 22:29:48 -04:00
commit 9a3187e36c
2 changed files with 33 additions and 8 deletions

View file

@ -4,4 +4,5 @@ import logging
logging.getLogger(__name__).addHandler(logging.NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
__version__ = (0, 2, 0) version = (0, 2, 0)
__version__ = ".".join([str(x) for x in version])

View file

@ -897,6 +897,9 @@ class LBRYumWallet(LBRYWallet):
self.cmd_runner = None self.cmd_runner = None
self.first_run = False self.first_run = False
self.printed_retrieving_headers = False self.printed_retrieving_headers = False
self._start_check = None
self._catch_up_check = None
self._caught_up_counter = 0
def _start(self): def _start(self):
@ -916,21 +919,30 @@ class LBRYumWallet(LBRYWallet):
alert.info("Running the wallet for the first time...this may take a moment.") alert.info("Running the wallet for the first time...this may take a moment.")
self.printed_retrieving_headers = True self.printed_retrieving_headers = True
return False return False
start_check.stop() self._start_check.stop()
self._start_check = None
if self.network.is_connected(): if self.network.is_connected():
network_start_d.callback(True) network_start_d.callback(True)
else: else:
network_start_d.errback(ValueError("Failed to connect to network.")) network_start_d.errback(ValueError("Failed to connect to network."))
start_check = task.LoopingCall(check_started) self._start_check = task.LoopingCall(check_started)
d.addCallback(lambda _: 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_wallet())
d.addCallback(lambda _: self._get_cmd_runner()) d.addCallback(lambda _: self._get_cmd_runner())
return d return d
def _stop(self): def _stop(self):
if self._start_check is not None:
self._start_check.stop()
self._start_check = None
if self._catch_up_check is not None:
self._catch_up_check.stop()
self._catch_up_check = None
d = defer.Deferred() d = defer.Deferred()
def check_stopped(): def check_stopped():
@ -970,16 +982,28 @@ class LBRYumWallet(LBRYWallet):
remote_height = self.network.get_server_height() remote_height = self.network.get_server_height()
if remote_height != 0 and remote_height - local_height <= 5: if remote_height != 0 and remote_height - local_height <= 5:
alert.info('Wallet loaded.') msg = ""
catch_up_check.stop() if self._caught_up_counter != 0:
msg += "All caught up. "
msg += "Wallet loaded."
alert.info(msg)
self._catch_up_check.stop()
self._catch_up_check = None
blockchain_caught_d.callback(True) blockchain_caught_d.callback(True)
elif remote_height != 0:
if self._caught_up_counter == 0:
alert.info('Catching up to the blockchain...showing blocks left...')
if self._caught_up_counter % 30 == 0:
alert.info('%d...', (remote_height - local_height))
self._caught_up_counter += 1
catch_up_check = task.LoopingCall(check_caught_up)
self._catch_up_check = task.LoopingCall(check_caught_up)
d = threads.deferToThread(get_wallet) d = threads.deferToThread(get_wallet)
d.addCallback(self._save_wallet) d.addCallback(self._save_wallet)
d.addCallback(lambda _: self.wallet.start_threads(self.network)) d.addCallback(lambda _: self.wallet.start_threads(self.network))
d.addCallback(lambda _: catch_up_check.start(.1)) d.addCallback(lambda _: self._catch_up_check.start(.1))
d.addCallback(lambda _: blockchain_caught_d) d.addCallback(lambda _: blockchain_caught_d)
return d return d