Include provider_uri in configuration.

pull/465/head
Kieran Prasch 2018-09-26 14:35:49 -07:00
parent 589e7e61a0
commit 9cce9f1ae7
3 changed files with 37 additions and 21 deletions

View File

@ -639,7 +639,7 @@ def status(config, provider, contracts, network):
MinerEscrow .............. {escrow}
PolicyManager ............ {manager}
""".format(registry_filepath=config.blockchain.interface.registry_filepath,
""".format(registry_filepath=config.blockchain.interface.filepath,
token=config.token_agent.contract_address,
escrow=config.miner_agent.contract_address,
manager=config.policy_agent.contract_address,
@ -684,12 +684,14 @@ def status(config, provider, contracts, network):
@click.option('--rest-host', type=str)
@click.option('--rest-port', type=int)
@click.option('--db-name', type=str)
@click.option('--blockchain-uri', type=str)
@click.option('--checksum-address', type=str)
@click.option('--metadata-dir', type=click.Path())
@click.option('--config-file', type=click.Path())
def run_ursula(rest_port,
rest_host,
db_name,
blockchain_uri,
checksum_address,
federated_only,
metadata_dir,
@ -726,18 +728,23 @@ def run_ursula(rest_port,
db_name=db_name,
is_me=True,
federated_only=federated_only,
blockchain_uri=blockchain_uri,
checksum_address=checksum_address,
# save_metadata=False, # TODO
load_metadata=True,
known_metadata_dir=metadata_dir,
start_learning_now=True,
abort_on_learning_error=temp)
try:
URSULA = ursula_config.produce()
URSULA.get_deployer().run() # Run TLS Deploy (Reactor)
if not URSULA.federated_only: # TODO: Resume / Init
URSULA.stake() # Start Staking Daemon
finally:
click.echo("Cleaning up temporary runtime files and directories")
ursula_config.cleanup() # TODO: Integrate with other "graceful" shutdown functionality
click.echo("Exited gracefully")

View File

@ -5,7 +5,8 @@ from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
from cryptography.x509 import Certificate
from nucypher.blockchain.eth.agents import EthereumContractAgent
from nucypher.blockchain.eth.agents import EthereumContractAgent, NucypherTokenAgent
from nucypher.blockchain.eth.chains import Blockchain
from nucypher.config.constants import DEFAULT_CONFIG_FILE_LOCATION
from nucypher.config.node import NodeConfiguration
from nucypher.crypto.powers import CryptoPower
@ -36,6 +37,7 @@ class UrsulaConfiguration(NodeConfiguration):
crypto_power: CryptoPower = None,
# Blockchain
blockchain_uri: str = None,
miner_agent: EthereumContractAgent = None,
checksum_address: str = None,
@ -62,8 +64,9 @@ class UrsulaConfiguration(NodeConfiguration):
#
# Blockchain
#
self.miner_agent = miner_agent
self.blockchain_uri = blockchain_uri
self.checksum_address = checksum_address
self.miner_agent = miner_agent
super().__init__(*args, **kwargs)
@ -86,27 +89,26 @@ class UrsulaConfiguration(NodeConfiguration):
def payload(self) -> dict:
ursula_payload = dict(
# REST
rest_host=self.rest_host,
rest_port=self.rest_port,
db_name=self.db_name,
db_filepath=self.db_filepath,
# REST
rest_host=self.rest_host,
rest_port=self.rest_port,
db_name=self.db_name,
db_filepath=self.db_filepath,
# TLS
tls_curve=self.tls_curve,
tls_private_key=self.tls_private_key,
certificate=self.certificate,
# certificate_filepath=self.certificate_filepath, # TODO: Handle existing certificates, injecting the path
# TLS
tls_curve=self.tls_curve,
tls_private_key=self.tls_private_key,
certificate=self.certificate,
# certificate_filepath=self.certificate_filepath, # TODO: Handle existing certificates, injecting the path
# Ursula
interface_signature=self.interface_signature,
crypto_power=self.crypto_power,
# Ursula
interface_signature=self.interface_signature,
crypto_power=self.crypto_power,
# Blockchain
miner_agent=self.miner_agent,
checksum_address=self.checksum_address,
registry_filepath=self.registry_filepath
# Blockchain
checksum_address=self.checksum_address,
registry_filepath=self.registry_filepath,
miner_agent=self.miner_agent
)
base_payload = super().payload
@ -116,6 +118,12 @@ class UrsulaConfiguration(NodeConfiguration):
def produce(self, **overrides):
merged_parameters = {**self.payload, **overrides}
from nucypher.characters.lawful import Ursula
if self.federated_only is False:
blockchain = Blockchain.connect(provider_uri=self.blockchain_uri) # TODO: move this..?
token_agent = NucypherTokenAgent(blockchain=blockchain)
merged_parameters.update(token_agent=token_agent)
ursula = Ursula(**merged_parameters)
# if self.save_metadata: # TODO: Does this belong here..?

View File

@ -1,4 +1,5 @@
import contextlib
import json
import os
from glob import glob
from os.path import abspath