mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-01 09:45:13 +00:00
enable checking first run status multiple times
This commit is contained in:
parent
f272a9ead2
commit
a68d891770
4 changed files with 24 additions and 6 deletions
|
@ -50,6 +50,10 @@ class LBRYWallet(object):
|
||||||
"""This class implements the LBRYWallet interface for the LBRYcrd payment system"""
|
"""This class implements the LBRYWallet interface for the LBRYcrd payment system"""
|
||||||
implements(ILBRYWallet)
|
implements(ILBRYWallet)
|
||||||
|
|
||||||
|
_FIRST_RUN_UNKNOWN = 0
|
||||||
|
_FIRST_RUN_YES = 1
|
||||||
|
_FIRST_RUN_NO = 2
|
||||||
|
|
||||||
def __init__(self, db_dir):
|
def __init__(self, db_dir):
|
||||||
|
|
||||||
self.db_dir = db_dir
|
self.db_dir = db_dir
|
||||||
|
@ -70,6 +74,7 @@ class LBRYWallet(object):
|
||||||
self._manage_count = 0
|
self._manage_count = 0
|
||||||
self._balance_refresh_time = 3
|
self._balance_refresh_time = 3
|
||||||
self._batch_count = 20
|
self._batch_count = 20
|
||||||
|
self._first_run = self._FIRST_RUN_UNKNOWN
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
||||||
|
@ -419,6 +424,19 @@ class LBRYWallet(object):
|
||||||
def get_available_balance(self):
|
def get_available_balance(self):
|
||||||
return float(self.wallet_balance - self.total_reserved_points)
|
return float(self.wallet_balance - self.total_reserved_points)
|
||||||
|
|
||||||
|
def is_first_run(self):
|
||||||
|
if self._first_run == self._FIRST_RUN_UNKNOWN:
|
||||||
|
d = self._check_first_run()
|
||||||
|
|
||||||
|
def set_first_run(is_first):
|
||||||
|
self._first_run = self._FIRST_RUN_YES if is_first else self._FIRST_RUN_NO
|
||||||
|
|
||||||
|
d.addCallback(set_first_run)
|
||||||
|
else:
|
||||||
|
d = defer.succeed(None)
|
||||||
|
d.addCallback(lambda _: self._first_run == self._FIRST_RUN_YES)
|
||||||
|
return d
|
||||||
|
|
||||||
def _get_status_of_claim(self, txid, name, sd_hash):
|
def _get_status_of_claim(self, txid, name, sd_hash):
|
||||||
d = self.get_claims_from_tx(txid)
|
d = self.get_claims_from_tx(txid)
|
||||||
|
|
||||||
|
@ -534,7 +552,7 @@ class LBRYWallet(object):
|
||||||
def get_name_claims(self):
|
def get_name_claims(self):
|
||||||
return defer.fail(NotImplementedError())
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
def check_first_run(self):
|
def _check_first_run(self):
|
||||||
return defer.fail(NotImplementedError())
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
def _get_raw_tx(self, txid):
|
def _get_raw_tx(self, txid):
|
||||||
|
@ -614,7 +632,7 @@ class LBRYcrdWallet(LBRYWallet):
|
||||||
settings["rpc_port"] = int(l[8:].rstrip('\n'))
|
settings["rpc_port"] = int(l[8:].rstrip('\n'))
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
def check_first_run(self):
|
def _check_first_run(self):
|
||||||
d = self.get_balance()
|
d = self.get_balance()
|
||||||
d.addCallback(lambda bal: threads.deferToThread(self._get_num_addresses_rpc) if bal == 0 else 2)
|
d.addCallback(lambda bal: threads.deferToThread(self._get_num_addresses_rpc) if bal == 0 else 2)
|
||||||
d.addCallback(lambda num_addresses: True if num_addresses <= 1 else False)
|
d.addCallback(lambda num_addresses: True if num_addresses <= 1 else False)
|
||||||
|
@ -996,7 +1014,7 @@ class LBRYumWallet(LBRYWallet):
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(self.cmd_runner, cmd.name)
|
||||||
return threads.deferToThread(func)
|
return threads.deferToThread(func)
|
||||||
|
|
||||||
def check_first_run(self):
|
def _check_first_run(self):
|
||||||
return defer.succeed(self.first_run)
|
return defer.succeed(self.first_run)
|
||||||
|
|
||||||
def _get_raw_tx(self, txid):
|
def _get_raw_tx(self, txid):
|
||||||
|
|
|
@ -253,7 +253,7 @@ class LBRYConsole():
|
||||||
return dl
|
return dl
|
||||||
|
|
||||||
def check_first_run(self):
|
def check_first_run(self):
|
||||||
d = self.session.wallet.check_first_run()
|
d = self.session.wallet.is_first_run()
|
||||||
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
return dl
|
return dl
|
||||||
|
|
||||||
def _check_first_run(self):
|
def _check_first_run(self):
|
||||||
d = self.session.wallet.check_first_run()
|
d = self.session.wallet.is_first_run()
|
||||||
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ class LBRYDownloader(object):
|
||||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_opener_factory)
|
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_opener_factory)
|
||||||
|
|
||||||
def check_first_run(self):
|
def check_first_run(self):
|
||||||
d = self.session.wallet.check_first_run()
|
d = self.session.wallet.is_first_run()
|
||||||
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue