示例#1
0
文件: plugin.py 项目: Artabaz/trinity
    def setup_eth1_modules(
            self,
            trinity_config: TrinityConfig) -> Tuple[Eth1ChainRPCModule, ...]:
        db_manager = create_db_manager(trinity_config.database_ipc_path)
        db_manager.connect()

        eth1_app_config = trinity_config.get_app_config(Eth1AppConfig)
        chain_config = trinity_config.get_chain_config()

        chain: BaseAsyncChain

        if eth1_app_config.is_light_mode:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_config.light_chain_class(
                header_db, peer_chain=event_bus_light_peer_chain)
        elif eth1_app_config.is_full_mode:
            db = db_manager.get_db()  # type: ignore
            chain = chain_config.full_chain_class(db)
        else:
            raise NotImplementedError(
                f"Unsupported mode: {trinity_config.sync_mode}")

        return initialize_eth1_modules(chain, self.event_bus)
示例#2
0
文件: plugin.py 项目: nrryuya/trinity
    def setup_eth1_modules(
            self,
            trinity_config: TrinityConfig) -> Tuple[Eth1ChainRPCModule, ...]:
        db_manager = create_db_consumer_manager(
            trinity_config.database_ipc_path)

        eth1_app_config = trinity_config.get_app_config(Eth1AppConfig)
        chain_config = trinity_config.get_chain_config()

        chain: BaseAsyncChain

        if eth1_app_config.database_mode is Eth1DbMode.LIGHT:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_config.light_chain_class(
                header_db, peer_chain=event_bus_light_peer_chain)
        elif eth1_app_config.database_mode is Eth1DbMode.FULL:
            db = db_manager.get_db()  # type: ignore
            chain = chain_config.full_chain_class(db)
        else:
            raise Exception(
                f"Unsupported Database Mode: {eth1_app_config.database_mode}")

        return initialize_eth1_modules(chain, self.event_bus)
示例#3
0
文件: plugin.py 项目: wimel/py-evm
    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()
示例#4
0
    def do_start(self) -> None:
        db_manager = create_db_manager(
            self.context.trinity_config.database_ipc_path)
        db_manager.connect()

        trinity_config = self.context.trinity_config
        eth1_app_config = self.context.trinity_config.get_app_config(
            Eth1AppConfig)
        chain_config = trinity_config.get_chain_config()

        chain: BaseAsyncChain

        if eth1_app_config.is_light_mode:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_config.light_chain_class(
                header_db, peer_chain=event_bus_light_peer_chain)
        elif eth1_app_config.is_full_mode:
            db = db_manager.get_db()  # type: ignore
            chain = chain_config.full_chain_class(db)
        else:
            raise NotImplementedError(
                f"Unsupported mode: {trinity_config.sync_mode}")

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

        loop = asyncio.get_event_loop()
        asyncio.ensure_future(
            exit_with_service_and_endpoint(ipc_server, self.context.event_bus))
        asyncio.ensure_future(ipc_server.run())
        loop.run_forever()
        loop.close()
示例#5
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
示例#6
0
    def get_chain(self) -> BaseChain:
        db_manager = create_db_consumer_manager(self.boot_info.trinity_config.database_ipc_path)

        chain_config = self.boot_info.trinity_config.get_chain_config()

        chain: BaseChain

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

        return chain