forked from LBRYCommunity/lbry-sdk
add waiting_for_credits startup code
This commit is contained in:
parent
20f423a2fc
commit
f985a2a8ad
1 changed files with 11 additions and 2 deletions
|
@ -74,13 +74,15 @@ LOADING_WALLET_CODE = 'loading_wallet'
|
||||||
LOADING_FILE_MANAGER_CODE = 'loading_file_manager'
|
LOADING_FILE_MANAGER_CODE = 'loading_file_manager'
|
||||||
LOADING_SERVER_CODE = 'loading_server'
|
LOADING_SERVER_CODE = 'loading_server'
|
||||||
STARTED_CODE = 'started'
|
STARTED_CODE = 'started'
|
||||||
|
WAITING_FOR_FIRST_RUN_CREDITS = 'waiting_for_credits'
|
||||||
STARTUP_STAGES = [
|
STARTUP_STAGES = [
|
||||||
(INITIALIZING_CODE, 'Initializing...'),
|
(INITIALIZING_CODE, 'Initializing...'),
|
||||||
(LOADING_DB_CODE, 'Loading databases...'),
|
(LOADING_DB_CODE, 'Loading databases...'),
|
||||||
(LOADING_WALLET_CODE, 'Catching up with the blockchain... %s'),
|
(LOADING_WALLET_CODE, 'Catching up with the blockchain... %s'),
|
||||||
(LOADING_FILE_MANAGER_CODE, 'Setting up file manager'),
|
(LOADING_FILE_MANAGER_CODE, 'Setting up file manager'),
|
||||||
(LOADING_SERVER_CODE, 'Starting lbrynet'),
|
(LOADING_SERVER_CODE, 'Starting lbrynet'),
|
||||||
(STARTED_CODE, 'Started lbrynet')
|
(STARTED_CODE, 'Started lbrynet'),
|
||||||
|
(WAITING_FOR_FIRST_RUN_CREDITS, 'Waiting for first run credits...')
|
||||||
]
|
]
|
||||||
|
|
||||||
DOWNLOAD_METADATA_CODE = 'downloading_metadata'
|
DOWNLOAD_METADATA_CODE = 'downloading_metadata'
|
||||||
|
@ -372,6 +374,13 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _announce_startup():
|
def _announce_startup():
|
||||||
|
def _wait_for_credits():
|
||||||
|
if float(self.session.wallet.wallet_balance) == 0.0:
|
||||||
|
self.startup_status = STARTUP_STAGES[6]
|
||||||
|
return reactor.callLater(1, _wait_for_credits)
|
||||||
|
else:
|
||||||
|
return _announce()
|
||||||
|
|
||||||
def _announce():
|
def _announce():
|
||||||
self.announced_startup = True
|
self.announced_startup = True
|
||||||
self.startup_status = STARTUP_STAGES[5]
|
self.startup_status = STARTUP_STAGES[5]
|
||||||
|
@ -387,7 +396,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
d.addCallback(lambda _: self._check_first_run())
|
d.addCallback(lambda _: self._check_first_run())
|
||||||
d.addCallback(self._show_first_run_result)
|
d.addCallback(self._show_first_run_result)
|
||||||
|
|
||||||
d.addCallback(lambda _: _announce())
|
d.addCallback(lambda _: _wait_for_credits() if self.requested_first_run_credits else _announce())
|
||||||
return d
|
return d
|
||||||
|
|
||||||
log.info("[" + str(datetime.now()) + "] Starting lbrynet-daemon")
|
log.info("[" + str(datetime.now()) + "] Starting lbrynet-daemon")
|
||||||
|
|
Loading…
Reference in a new issue