예제 #1
0
def run_ursula(rest_port, dht_port, db_name, checksum_address, federated_only,
               seed_node, data_dir, config_file) -> None:
    """

    The following procedure is required to "spin-up" an Ursula node.

        1. Collect all known known from storages
        2. Start the asyncio event loop
        3. Initialize Ursula object
        4. Start DHT listener
        5. Enter the learning loop
        6. Run TLS deployment
        7. Start the staking daemon

    Configurable values are first read from the .ini configuration file,
    but can be overridden (mostly for testing purposes) with inline cli options.

    """

    if not seed_node:
        other_nodes = collect_stored_nodes(
            federated_only=federated_only)  # 1. Collect known nodes
    else:
        other_nodes = tuple()

    overrides = dict(federated_only=federated_only,
                     known_nodes=other_nodes,
                     rest_port=rest_port,
                     dht_port=dht_port,
                     db_name=db_name,
                     checksum_address=checksum_address)

    if seed_node:
        seed_overrides = dict(always_be_learning=False,
                              abort_on_learning_error=False)

        overrides.update(seed_overrides)

    asyncio.set_event_loop(asyncio.new_event_loop())  # 2. Init DHT async loop

    # 3. Initialize Ursula (includes overrides)
    ursula = Ursula.from_config(filepath=config_file, overrides=overrides)

    ursula.dht_listen()  # 4. Start DHT

    write_node_metadata(seed_node=seed_node,
                        node=ursula,
                        node_metadata_dir=data_dir)

    if not seed_node:
        ursula.start_learning_loop()  # 5. Enter learning loop

    ursula.get_deployer().run()  # 6. Run TLS Deployer

    if not federated_only:
        ursula.stake()  # 7. start staking daemon
예제 #2
0
from nucypher.config.metadata import collect_stored_nodes
from nucypher.data_sources import DataSource
# This is already running in another process.
from nucypher.network.middleware import RestMiddleware
>>>>>>> 26103ab... Project-wide automated import optimization, followed-up with some hand-tweaking:examples/finnegans-wake-demo.py

# This is already running in another process.


##############################################
# This is already running in another process.
##############################################

BLOCKCHAIN = Blockchain.connect()

URSULA = Ursula.from_config()

#########
# Alice #
#########

ALICE = Alice.from_config()

# Here are our Policy details.
policy_end_datetime = maya.now() + datetime.timedelta(days=201)
m = 2
n = 3
label = b"secret/files/and/stuff"

# Alice grants to Bob.
BOB = Bob.from_config()