Ejemplo n.º 1
0
    def start(self) -> None:
        self.logger.info('JSON-RPC Server started')
        self.context.event_bus.connect()

        db_manager = create_db_manager(
            self.context.chain_config.database_ipc_path)
        db_manager.connect()

        chain_class = self.context.chain_config.node_class.chain_class

        if self.context.chain_config.sync_mode == SYNC_LIGHT:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_class(header_db,
                                peer_chain=event_bus_light_peer_chain)
        else:
            db = db_manager.get_db()  # type: ignore
            chain = chain_class(db)

        rpc = RPCServer(chain, self.context.event_bus)
        ipc_server = IPCServer(rpc, self.context.chain_config.jsonrpc_ipc_path)

        loop = asyncio.get_event_loop()
        asyncio.ensure_future(
            exit_on_signal(ipc_server, self.context.event_bus))
        asyncio.ensure_future(ipc_server.run())
        loop.run_forever()
        loop.close()
Ejemplo n.º 2
0
    def __init__(self, plugin_manager: PluginManager,
                 trinity_config: TrinityConfig) -> None:
        super().__init__()
        self._plugin_manager = plugin_manager
        self._db_manager = create_db_manager(trinity_config.database_ipc_path)
        self._db_manager.connect()  # type: ignore
        self._headerdb = self._db_manager.get_headerdb()  # type: ignore

        self._jsonrpc_ipc_path: Path = trinity_config.jsonrpc_ipc_path
Ejemplo n.º 3
0
    def get_chain(self) -> BaseChain:
        db_manager = create_db_manager(
            self.context.chain_config.database_ipc_path)
        db_manager.connect()

        chain_class = self.context.chain_config.node_class.chain_class

        if self.context.chain_config.sync_mode == SYNC_LIGHT:
            header_db = db_manager.get_headerdb()  # type: ignore
            chain = chain_class(header_db,
                                peer_chain=EventBusLightPeerChain(
                                    self.context.event_bus))
        else:
            db = db_manager.get_db()  # type: ignore
            chain = chain_class(db)

        return chain