def get_eth1_chain_with_remote_db( boot_info: BootInfo, event_bus: EndpointAPI) -> Iterator[ChainAPI]: app_config = boot_info.trinity_config.get_app_config(Eth1AppConfig) chain_config = app_config.get_chain_config() chain: ChainAPI base_db = DBClient.connect(boot_info.trinity_config.database_ipc_path) with base_db: if boot_info.args.sync_mode == SYNC_LIGHT: header_db = AsyncHeaderDB(base_db) chain = chain_config.light_chain_class( header_db, peer_chain=EventBusLightPeerChain(event_bus)) else: chain = chain_config.full_chain_class(base_db) yield chain
def chain_for_eth1_config(self, trinity_config: TrinityConfig, eth1_app_config: Eth1AppConfig) -> AsyncChainAPI: chain_config = eth1_app_config.get_chain_config() db = DBClient.connect(trinity_config.database_ipc_path) if eth1_app_config.database_mode is Eth1DbMode.LIGHT: header_db = HeaderDB(db) event_bus_light_peer_chain = EventBusLightPeerChain(self.event_bus) return chain_config.light_chain_class( header_db, peer_chain=event_bus_light_peer_chain) elif eth1_app_config.database_mode is Eth1DbMode.FULL: return chain_config.full_chain_class(db) else: raise Exception( f"Unsupported Database Mode: {eth1_app_config.database_mode}")
def get_chain(self) -> ChainAPI: app_config = self.boot_info.trinity_config.get_app_config( Eth1AppConfig) chain_config = app_config.get_chain_config() chain: ChainAPI base_db = DBClient.connect( self.boot_info.trinity_config.database_ipc_path) if self.boot_info.args.sync_mode == SYNC_LIGHT: header_db = AsyncHeaderDB(base_db) chain = chain_config.light_chain_class( header_db, peer_chain=EventBusLightPeerChain(self.event_bus)) else: chain = chain_config.full_chain_class(base_db) return chain
def chain_for_eth1_config(trinity_config: TrinityConfig, eth1_app_config: Eth1AppConfig, event_bus: EndpointAPI) -> Iterator[AsyncChainAPI]: chain_config = eth1_app_config.get_chain_config() db = DBClient.connect(trinity_config.database_ipc_path) with db: if eth1_app_config.database_mode is Eth1DbMode.LIGHT: header_db = HeaderDB(db) event_bus_light_peer_chain = EventBusLightPeerChain(event_bus) yield chain_config.light_chain_class( header_db, peer_chain=event_bus_light_peer_chain ) elif eth1_app_config.database_mode is Eth1DbMode.FULL: yield chain_config.full_chain_class(db) else: raise Exception(f"Unsupported Database Mode: {eth1_app_config.database_mode}")
def get_chain(self) -> BaseChain: db_manager = create_db_consumer_manager( self.boot_info.trinity_config.database_ipc_path) app_config = self.boot_info.trinity_config.get_app_config( Eth1AppConfig) chain_config = app_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
def setup_eth1_modules( self, trinity_config: TrinityConfig) -> Tuple[BaseRPCModule, ...]: db_manager = create_db_consumer_manager( trinity_config.database_ipc_path) eth1_app_config = trinity_config.get_app_config(Eth1AppConfig) chain_config = eth1_app_config.get_chain_config() chain: BaseAsyncChain if eth1_app_config.database_mode is Eth1DbMode.LIGHT: db = db_manager.get_db() # type: ignore header_db = HeaderDB(db) event_bus_light_peer_chain = EventBusLightPeerChain(self.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)