forked from LBRYCommunity/lbry-sdk
Move the go hub settings from network to ledger config and hook reset
correctly.
This commit is contained in:
parent
9b78501392
commit
4544a074d9
4 changed files with 10 additions and 6 deletions
|
@ -2612,8 +2612,11 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
Returns: {Paginated[Output]}
|
||||
"""
|
||||
# if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
|
||||
if self.ledger.network.use_go_hub:
|
||||
kwargs_old = copy.copy(kwargs)
|
||||
if self.ledger.config['use_go_hub']:
|
||||
if self.ledger.config['first_search']:
|
||||
# Only do this the first time because we might need to retry due to the go hub not being there
|
||||
self.ledger.config['first_search'] = False
|
||||
kwargs_old = copy.copy(kwargs)
|
||||
host = self.ledger.network.client.server[0]
|
||||
# host = os.environ.get("HUB_HOST", "localhost")
|
||||
port = os.environ.get("HUB_PORT", "50051")
|
||||
|
@ -2656,9 +2659,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
result['total_items'] = total
|
||||
return result
|
||||
except Exception as e:
|
||||
if self.ledger.network.use_go_hub:
|
||||
if self.ledger.config['use_go_hub']:
|
||||
log.warning("failed, trying again without hub")
|
||||
self.ledger.network.use_go_hub = False
|
||||
self.ledger.config['use_go_hub'] = False
|
||||
return await self.jsonrpc_claim_search(**kwargs_old)
|
||||
raise e
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ class Ledger(metaclass=LedgerRegistry):
|
|||
|
||||
def __init__(self, config=None):
|
||||
self.config = config or {}
|
||||
self.config.update({"use_go_hub": True, "first_search": True})
|
||||
self.db: Database = self.config.get('db') or Database(
|
||||
os.path.join(self.path, "blockchain.db")
|
||||
)
|
||||
|
|
|
@ -233,6 +233,8 @@ class WalletManager:
|
|||
|
||||
async def reset(self):
|
||||
self.ledger.config = {
|
||||
'use_go_hub': True,
|
||||
'first_search': True,
|
||||
'auto_connect': True,
|
||||
'explicit_servers': [],
|
||||
'default_servers': Config.lbryum_servers.default,
|
||||
|
|
|
@ -156,7 +156,6 @@ class Network:
|
|||
MINIMUM_REQUIRED = (0, 65, 0)
|
||||
|
||||
def __init__(self, ledger):
|
||||
self.use_go_hub = True
|
||||
self.ledger = ledger
|
||||
self.client: Optional[ClientSession] = None
|
||||
self.server_features = None
|
||||
|
@ -208,7 +207,6 @@ class Network:
|
|||
|
||||
async def start(self):
|
||||
if not self.running:
|
||||
self.use_go_hub = True
|
||||
self.running = True
|
||||
self.aiohttp_session = aiohttp.ClientSession()
|
||||
self.on_header.listen(self._update_remote_height)
|
||||
|
|
Loading…
Reference in a new issue