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,7 +2612,10 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
Returns: {Paginated[Output]}
|
Returns: {Paginated[Output]}
|
||||||
"""
|
"""
|
||||||
# if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
|
# if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
|
||||||
if self.ledger.network.use_go_hub:
|
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)
|
kwargs_old = copy.copy(kwargs)
|
||||||
host = self.ledger.network.client.server[0]
|
host = self.ledger.network.client.server[0]
|
||||||
# host = os.environ.get("HUB_HOST", "localhost")
|
# host = os.environ.get("HUB_HOST", "localhost")
|
||||||
|
@ -2656,9 +2659,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
result['total_items'] = total
|
result['total_items'] = total
|
||||||
return result
|
return result
|
||||||
except Exception as e:
|
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")
|
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)
|
return await self.jsonrpc_claim_search(**kwargs_old)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||||
|
|
||||||
def __init__(self, config=None):
|
def __init__(self, config=None):
|
||||||
self.config = config or {}
|
self.config = config or {}
|
||||||
|
self.config.update({"use_go_hub": True, "first_search": True})
|
||||||
self.db: Database = self.config.get('db') or Database(
|
self.db: Database = self.config.get('db') or Database(
|
||||||
os.path.join(self.path, "blockchain.db")
|
os.path.join(self.path, "blockchain.db")
|
||||||
)
|
)
|
||||||
|
|
|
@ -233,6 +233,8 @@ class WalletManager:
|
||||||
|
|
||||||
async def reset(self):
|
async def reset(self):
|
||||||
self.ledger.config = {
|
self.ledger.config = {
|
||||||
|
'use_go_hub': True,
|
||||||
|
'first_search': True,
|
||||||
'auto_connect': True,
|
'auto_connect': True,
|
||||||
'explicit_servers': [],
|
'explicit_servers': [],
|
||||||
'default_servers': Config.lbryum_servers.default,
|
'default_servers': Config.lbryum_servers.default,
|
||||||
|
|
|
@ -156,7 +156,6 @@ class Network:
|
||||||
MINIMUM_REQUIRED = (0, 65, 0)
|
MINIMUM_REQUIRED = (0, 65, 0)
|
||||||
|
|
||||||
def __init__(self, ledger):
|
def __init__(self, ledger):
|
||||||
self.use_go_hub = True
|
|
||||||
self.ledger = ledger
|
self.ledger = ledger
|
||||||
self.client: Optional[ClientSession] = None
|
self.client: Optional[ClientSession] = None
|
||||||
self.server_features = None
|
self.server_features = None
|
||||||
|
@ -208,7 +207,6 @@ class Network:
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
if not self.running:
|
if not self.running:
|
||||||
self.use_go_hub = True
|
|
||||||
self.running = True
|
self.running = True
|
||||||
self.aiohttp_session = aiohttp.ClientSession()
|
self.aiohttp_session = aiohttp.ClientSession()
|
||||||
self.on_header.listen(self._update_remote_height)
|
self.on_header.listen(self._update_remote_height)
|
||||||
|
|
Loading…
Reference in a new issue