예제 #1
0
 def chain_for_config(self, trinity_config: TrinityConfig) -> AsyncChainAPI:
     if trinity_config.has_app_config(BeaconAppConfig):
         return None
     elif trinity_config.has_app_config(Eth1AppConfig):
         eth1_app_config = trinity_config.get_app_config(Eth1AppConfig)
         return self.chain_for_eth1_config(trinity_config, eth1_app_config)
     else:
         raise Exception("Unsupported Node Type")
예제 #2
0
 def chain_for_config(
     self, trinity_config: TrinityConfig
 ) -> Union[AsyncChainAPI, AsyncBeaconChainDB]:
     if trinity_config.has_app_config(BeaconAppConfig):
         beacon_app_config = trinity_config.get_app_config(BeaconAppConfig)
         return self.chain_for_beacon_config(trinity_config,
                                             beacon_app_config)
     elif trinity_config.has_app_config(Eth1AppConfig):
         eth1_app_config = trinity_config.get_app_config(Eth1AppConfig)
         return self.chain_for_eth1_config(trinity_config, eth1_app_config)
     else:
         raise Exception("Unsupported Node Type")
예제 #3
0
def chain_for_config(trinity_config: TrinityConfig,
                     event_bus: EndpointAPI,
                     ) -> Iterator[Union[AsyncChainAPI, AsyncBeaconChainDB]]:
    if trinity_config.has_app_config(BeaconAppConfig):
        beacon_app_config = trinity_config.get_app_config(BeaconAppConfig)
        with chain_for_beacon_config(trinity_config, beacon_app_config) as beacon_chain:
            yield beacon_chain
    elif trinity_config.has_app_config(Eth1AppConfig):
        eth1_app_config = trinity_config.get_app_config(Eth1AppConfig)
        with chain_for_eth1_config(trinity_config, eth1_app_config, event_bus) as eth1_chain:
            yield eth1_chain
    else:
        raise Exception("Unsupported Node Type")
예제 #4
0
    def run_shell(cls, args: Namespace, trinity_config: TrinityConfig) -> None:
        config: BaseAppConfig

        if trinity_config.has_app_config(Eth1AppConfig):
            config = trinity_config.get_app_config(Eth1AppConfig)
            context = get_eth1_shell_context(config.database_dir, trinity_config)
            db_shell(is_ipython_available(), context)
        elif trinity_config.has_app_config(BeaconAppConfig):
            config = trinity_config.get_app_config(BeaconAppConfig)
            context = get_beacon_shell_context(config.database_dir, trinity_config)
            db_shell(is_ipython_available(), context)
        else:
            cls.logger.error(
                "DB Shell only supports the Ethereum 1 and Beacon nodes at this time"
            )
예제 #5
0
def test_trinity_config_sub_configs():
    trinity_config = TrinityConfig(network_id=1)
    trinity_config.initialize_app_configs(None, (BeaconAppConfig,))

    assert trinity_config.has_app_config(BeaconAppConfig)
    beacon_config = trinity_config.get_app_config(BeaconAppConfig)
    assert type(beacon_config) is BeaconAppConfig
예제 #6
0
파일: plugin.py 프로젝트: mhchia/trinity
    def run_shell(self, args: Namespace, trinity_config: TrinityConfig) -> None:

        if trinity_config.has_app_config(Eth1AppConfig):
            config = trinity_config.get_app_config(Eth1AppConfig)
            db_shell(self.use_ipython, config.database_dir, trinity_config)
        else:
            self.logger.error("DB Shell does only support the Ethereum 1 node at this time")
예제 #7
0
    def run_shell(cls, args: Namespace, trinity_config: TrinityConfig) -> None:

        if trinity_config.has_app_config(Eth1AppConfig):
            config = trinity_config.get_app_config(Eth1AppConfig)
            db_shell(is_ipython_available(), config.database_dir,
                     trinity_config)
        else:
            cls.get_logger().error(
                "DB Shell only supports the Ethereum 1 node at this time")
예제 #8
0
def get_protocol(trinity_config: TrinityConfig) -> Type[Protocol]:
    # For now DiscoveryByTopicProtocol supports a single topic, so we use the latest
    # version of our supported protocols. Maybe this could be more generic?
    # TODO: This needs to support the beacon protocol when we have a way to
    # check the config, if trinity is being run as a beacon node.

    if trinity_config.has_app_config(BeaconAppConfig):
        return BCCProtocol
    else:
        eth1_config = trinity_config.get_app_config(Eth1AppConfig)
        if eth1_config.is_light_mode:
            return LESProtocolV2
        else:
            return ETHProtocol