mirror of https://github.com/nucypher/nucypher.git
Fixed bug where teacher uri was not being used. Allow registry filepath to be specified.
parent
471d807c75
commit
ab4b001b1e
|
@ -20,9 +20,16 @@ from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
|||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.characters.lawful import Ursula
|
||||
from nucypher.cli.config import group_general_config
|
||||
from nucypher.cli.options import option_network, option_provider_uri, option_federated_only, option_teacher_uri
|
||||
from nucypher.cli.options import (
|
||||
option_network,
|
||||
option_provider_uri,
|
||||
option_federated_only,
|
||||
option_teacher_uri,
|
||||
option_registry_filepath
|
||||
)
|
||||
from nucypher.cli.types import NETWORK_PORT
|
||||
from nucypher.cli.utils import setup_emitter
|
||||
from nucypher.cli.utils import setup_emitter, get_registry
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
from nucypher.utilities.porter.control.interfaces import PorterInterface
|
||||
from nucypher.utilities.porter.porter import Porter
|
||||
|
||||
|
@ -82,10 +89,11 @@ def exec_work_order(general_config, porter_uri, ursula, work_order):
|
|||
@option_provider_uri(required=False)
|
||||
@option_federated_only
|
||||
@option_teacher_uri
|
||||
@option_registry_filepath
|
||||
@click.option('--http-port', help="Porter HTTP port for JSON endpoint", type=NETWORK_PORT, default=Porter.DEFAULT_PORTER_HTTP_PORT)
|
||||
@click.option('--dry-run', '-x', help="Execute normally without actually starting Porter", is_flag=True)
|
||||
@click.option('--eager', help="Start learning and scraping the network before starting up other services", is_flag=True, default=True)
|
||||
def run(general_config, network, provider_uri, federated_only, teacher_uri, http_port, dry_run, eager):
|
||||
def run(general_config, network, provider_uri, federated_only, teacher_uri, registry_filepath, http_port, dry_run, eager):
|
||||
"""Start Porter's Web controller."""
|
||||
emitter = setup_emitter(general_config, banner=Porter.BANNER)
|
||||
|
||||
|
@ -94,15 +102,16 @@ def run(general_config, network, provider_uri, federated_only, teacher_uri, http
|
|||
raise click.BadOptionUsage(option_name='--teacher',
|
||||
message="--teacher is required for federated porter.")
|
||||
|
||||
ursula = Ursula.from_seed_and_stake_info(seed_uri="localhost:11500",
|
||||
federated_only=True,
|
||||
minimum_stake=0)
|
||||
teacher = Ursula.from_teacher_uri(teacher_uri=teacher_uri,
|
||||
federated_only=True,
|
||||
min_stake=0)
|
||||
PORTER = Porter(domain=TEMPORARY_DOMAIN,
|
||||
start_learning_now=eager,
|
||||
known_nodes={ursula},
|
||||
known_nodes={teacher},
|
||||
verify_node_bonding=False,
|
||||
federated_only=True)
|
||||
else:
|
||||
# decentralized/blockchain
|
||||
if not provider_uri:
|
||||
raise click.BadOptionUsage(option_name='--provider',
|
||||
message="--provider is required for decentralized porter.")
|
||||
|
@ -110,8 +119,21 @@ def run(general_config, network, provider_uri, federated_only, teacher_uri, http
|
|||
raise click.BadOptionUsage(option_name='--network',
|
||||
message="--network is required for decentralized porter.")
|
||||
|
||||
registry = get_registry(network=network, registry_filepath=registry_filepath)
|
||||
network_middleware = RestMiddleware(registry=registry)
|
||||
BlockchainInterfaceFactory.initialize_interface(provider_uri=provider_uri)
|
||||
teacher = None
|
||||
if teacher_uri:
|
||||
teacher = Ursula.from_teacher_uri(teacher_uri=teacher_uri,
|
||||
federated_only=False, # always False
|
||||
min_stake=0,
|
||||
network_middleware=network_middleware,
|
||||
registry=registry)
|
||||
|
||||
PORTER = Porter(domain=network,
|
||||
network_middleware=network_middleware,
|
||||
known_nodes={teacher} if teacher else None,
|
||||
registry=registry,
|
||||
start_learning_now=eager,
|
||||
provider_uri=provider_uri)
|
||||
|
||||
|
@ -128,6 +150,6 @@ def run(general_config, network, provider_uri, federated_only, teacher_uri, http
|
|||
emitter.message(f"Provider: {provider_uri}", color='green')
|
||||
|
||||
controller = PORTER.make_web_controller(crash_on_error=False)
|
||||
message = f"Running Porter Web Controller at http://localhost:{http_port}"
|
||||
message = f"Running Porter Web Controller at http://127.0.0.1:{http_port}"
|
||||
emitter.message(message, color='green', bold=True)
|
||||
return controller.start(http_port=http_port, dry_run=dry_run)
|
||||
|
|
Loading…
Reference in New Issue