Beispiel #1
0
 def setUp(self):
     self.ctx = zmq.asyncio.Context()
     self.ctx.max_sockets = 50_000
     self.loop = asyncio.new_event_loop()
     asyncio.set_event_loop(self.loop)
     ContractingClient().flush()
     storage.BlockStorage().drop_collections()
Beispiel #2
0
    def __init__(self, ctx, index=1):
        super().__init__(ctx, index)

        self.webserver_port = 18080 + index
        self.webserver_ip = f'http://0.0.0.0:{self.webserver_port}'

        self.blocks = storage.BlockStorage(blocks_collection=f'blocks-{self.index}', tx_collection=f'tx-{self.index}')
        self.blocks.flush()
Beispiel #3
0
    def setUp(self):
        self.ctx = zmq.asyncio.Context()
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        self.authenticator = authentication.SocketAuthenticator(
            client=ContractingClient(), ctx=self.ctx)

        self.b = masternode.BlockService(blocks=storage.BlockStorage(),
                                         driver=ContractDriver())

        self.r = router.Router(socket_id='tcp://127.0.0.1:18001', ctx=self.ctx)

        self.r.add_service(base.BLOCK_SERVICE, self.b)
Beispiel #4
0
    def setUp(self):
        self.ctx = zmq.asyncio.Context()
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        self.blocks = storage.BlockStorage()

        self.driver = ContractDriver(driver=InMemDriver())
        self.b = masternode.BlockService(blocks=self.blocks,
                                         driver=self.driver)

        self.blocks.drop_collections()
        self.driver.flush()

        self.authenticator = authentication.SocketAuthenticator(
            client=ContractingClient(), ctx=self.ctx)
Beispiel #5
0
    def __init__(self,
                 socket_base,
                 ctx: zmq.asyncio.Context,
                 wallet,
                 constitution: dict,
                 bootnodes={},
                 blocks=storage.BlockStorage(),
                 driver=ContractDriver(),
                 debug=True,
                 store=False,
                 seed=None,
                 bypass_catchup=False,
                 node_type=None,
                 genesis_path=lamden.contracts.__path__[0],
                 reward_manager=rewards.RewardManager(),
                 nonces=storage.NonceStorage()):

        self.driver = driver
        self.nonces = nonces
        self.store = store

        self.seed = seed

        self.blocks = blocks
        self.event_writer = EventWriter()

        self.log = get_logger('Base')
        self.log.propagate = debug
        self.socket_base = socket_base
        self.wallet = wallet
        self.ctx = ctx

        self.genesis_path = genesis_path

        self.client = ContractingClient(driver=self.driver,
                                        submission_filename=genesis_path +
                                        '/submission.s.py')

        self.bootnodes = bootnodes
        self.constitution = constitution

        self.seed_genesis_contracts()

        self.socket_authenticator = authentication.SocketAuthenticator(
            bootnodes=self.bootnodes, ctx=self.ctx, client=self.client)

        self.upgrade_manager = upgrade.UpgradeManager(client=self.client,
                                                      wallet=self.wallet,
                                                      node_type=node_type)

        self.router = router.Router(socket_id=socket_base,
                                    ctx=self.ctx,
                                    wallet=wallet,
                                    secure=True)

        self.network = network.Network(wallet=wallet,
                                       ip_string=socket_base,
                                       ctx=self.ctx,
                                       router=self.router)

        self.new_block_processor = NewBlock(driver=self.driver)
        self.router.add_service(
            NEW_BLOCK_SERVICE,
            self.new_block_processor)  # Add this after catch up?

        self.running = False
        self.upgrade = False

        self.reward_manager = reward_manager

        self.current_height = storage.get_latest_block_height(self.driver)
        self.current_hash = storage.get_latest_block_hash(self.driver)

        self.bypass_catchup = bypass_catchup
Beispiel #6
0
        return response.json(
            {
                'masternodes': masternodes,
                'delegates': delegates
            },
            headers={'Access-Control-Allow-Origin': '*'})


if __name__ == '__main__':
    arg_parser = argparse.ArgumentParser(
        description='Standard Lamden HTTP Webserver')

    arg_parser.add_argument('-k', '--key', type=str, required=True)

    args = arg_parser.parse_args()

    sk = bytes.fromhex(args.key)
    wallet = Wallet(seed=sk)

    webserver = WebServer(contracting_client=ContractingClient(),
                          driver=storage.ContractDriver(),
                          blocks=storage.BlockStorage(),
                          wallet=wallet,
                          port=18080)

    webserver.app.run(host='0.0.0.0',
                      port=webserver.port,
                      debug=webserver.debug,
                      access_log=webserver.access_log)
Beispiel #7
0
 def setUp(self):
     self.client = storage.BlockStorage()
     self.client.flush()