def make_ursulas(how_many_ursulas: int, ursula_starting_port: int) -> list: """ :param how_many_ursulas: How many Ursulas to create. :param ursula_starting_port: The port of the first created Ursula; subsequent Ursulas will increment the port number by 1. :return: A list of created Ursulas """ event_loop = asyncio.get_event_loop() URSULAS = [] for _u in range(how_many_ursulas): engine = create_engine('sqlite:///:memory:') Base.metadata.create_all(engine) ursulas_keystore = keystore.KeyStore(engine) _URSULA = Ursula(urulsas_keystore=ursulas_keystore) _URSULA.attach_server() _URSULA.listen(ursula_starting_port + _u, "127.0.0.1") URSULAS.append(_URSULA) for _counter, ursula in enumerate(URSULAS): event_loop.run_until_complete( ursula.server.bootstrap([("127.0.0.1", ursula_starting_port + _c) for _c in range(how_many_ursulas)])) ursula.publish_dht_information() return URSULAS
def make_fake_ursulas(how_many): URSULAS = [] for _u in range(how_many): _URSULA = Ursula() _URSULA.attach_server() _URSULA.listen(URSULA_PORT + _u, "127.0.0.1") URSULAS.append(_URSULA) for _counter, ursula in enumerate(URSULAS): EVENT_LOOP.run_until_complete(ursula.server.bootstrap([("127.0.0.1", URSULA_PORT)])) EVENT_LOOP.run_until_complete(ursula.server.bootstrap([("127.0.0.1", URSULA_PORT + _counter)])) ursula.publish_interface_information() return URSULAS
# This is not an actual mining script. Don't use this to mine - you won't # perform any re-encryptions, and you won't get paid. # It might be (but might not be) useful for determining whether you have # the proper depedencies and configuration to run an actual mining node. # WIP w/ hendrix@8227c4abcb37ee6d27528a13ec22d55ee106107f from sqlalchemy.engine import create_engine from nkms.characters import Ursula from nkms.keystore import keystore from nkms.keystore.db import Base engine = create_engine('sqlite:///:memory:') Base.metadata.create_all(engine) ursulas_keystore = keystore.KeyStore(engine) _URSULA = Ursula(urulsas_keystore=ursulas_keystore) _URSULA.attach_server() from hendrix.deploy.base import HendrixDeploy deployer = HendrixDeploy("start", { "wsgi": _URSULA._rest_app, "http_port": 3500 }) deployer.run()