diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8f0430191..b3ee978a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,6 +79,7 @@ jobs: - datanetwork - blockchain - other + hub_type: ['legacy_hub', 'new_hub'] steps: - name: Configure sysctl limits run: | @@ -105,7 +106,10 @@ jobs: key: tox-integration-${{ matrix.test }}-${{ hashFiles('setup.py') }} restore-keys: txo-integration-${{ matrix.test }}- - run: pip install tox coverage coveralls - - run: tox -e ${{ matrix.test }} + - name: run tox + env: + ENABLE_LEGACY_SEARCH: ${{ matrix.hub_type == 'legacy_hub' }} + run: tox -e ${{ matrix.test }} - name: submit coverage report env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 1b4534c70..bb0acc6e2 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -364,7 +364,6 @@ class Daemon(metaclass=JSONRPCServerType): ) def __init__(self, conf: Config, component_manager: typing.Optional[ComponentManager] = None): - self.use_go_hub = True self.conf = conf self.platform_info = system_info.get_platform() self._video_file_analyzer = VideoFileAnalyzer(conf) @@ -2540,7 +2539,7 @@ class Daemon(metaclass=JSONRPCServerType): Returns: {Paginated[Output]} """ - if self.ledger.config['use_go_hub']: + if self.ledger.config.get('use_go_hub'): host = self.ledger.network.client.server[0] port = "50051" kwargs['new_sdk_server'] = f"{host}:{port}" diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 03c1f4539..211e3ef7a 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -112,7 +112,6 @@ class Ledger(metaclass=LedgerRegistry): def __init__(self, config=None): self.config = config or {} - self.config.update({"use_go_hub": True}) self.db: Database = self.config.get('db') or Database( os.path.join(self.path, "blockchain.db") ) diff --git a/lbry/wallet/manager.py b/lbry/wallet/manager.py index 4843ce1bb..438bcf2d5 100644 --- a/lbry/wallet/manager.py +++ b/lbry/wallet/manager.py @@ -3,6 +3,8 @@ import json import typing import logging import asyncio +from distutils.util import strtobool + from binascii import unhexlify from decimal import Decimal from typing import List, Type, MutableSequence, MutableMapping, Optional @@ -181,6 +183,7 @@ class WalletManager: }[config.blockchain_name] ledger_config = { + 'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'no'), 'auto_connect': True, 'explicit_servers': [], 'hub_timeout': config.hub_timeout, @@ -233,7 +236,7 @@ class WalletManager: async def reset(self): self.ledger.config = { - 'use_go_hub': True, + 'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'no'), 'auto_connect': True, 'explicit_servers': [], 'default_servers': Config.lbryum_servers.default, diff --git a/lbry/wallet/orchstr8/node.py b/lbry/wallet/orchstr8/node.py index caa6c638b..310137c7b 100644 --- a/lbry/wallet/orchstr8/node.py +++ b/lbry/wallet/orchstr8/node.py @@ -8,6 +8,8 @@ import logging import tempfile import subprocess import importlib +from distutils.util import strtobool + from binascii import hexlify from typing import Type, Optional import urllib.request @@ -144,6 +146,7 @@ class WalletNode: self.manager = self.manager_class.from_config({ 'ledgers': { self.ledger_class.get_id(): { + 'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'no'), 'api_port': self.port, 'explicit_servers': [(spv_node.hostname, spv_node.port)], 'default_servers': Config.lbryum_servers.default, @@ -555,7 +558,7 @@ class HubNode: loop = asyncio.get_event_loop() asyncio.get_child_watcher().attach_loop(loop) command = [ - self.daemon_bin, 'serve', '--esindex', self.spv_node.index_name + 'claims' + self.daemon_bin, 'serve', '--esindex', self.spv_node.index_name + 'claims', '--debug' ] self.log.info(' '.join(command)) while not self.stopped: @@ -591,23 +594,3 @@ class HubNode: def cleanup(self): pass - - async def _cli_cmnd(self, *args): - cmnd_args = [ - self.daemon_bin, - ] + list(args) - self.log.info(' '.join(cmnd_args)) - loop = asyncio.get_event_loop() - asyncio.get_child_watcher().attach_loop(loop) - process = await asyncio.create_subprocess_exec( - *cmnd_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT - ) - out, _ = await process.communicate() - result = out.decode().strip() - self.log.info(result) - if result.startswith('error code'): - raise Exception(result) - return result - - async def name_query(self, name): - return await self._cli_cmnd('--name', name) diff --git a/tox.ini b/tox.ini index 8f789478a..61c961c6f 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ changedir = {toxinidir}/tests setenv = HOME=/tmp ELASTIC_HOST={env:ELASTIC_HOST:localhost} - GO_HUB=true + ENABLE_LEGACY_SEARCH={env:ENABLE_LEGACY_SEARCH:0} commands = orchstr8 download blockchain: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.blockchain {posargs}