Config¶
This section covers Trinity’s configuration APIs that are being used within many internal components and are also exposed to the extensibility API.
This is not about Trinity’s command line configuration, which is covered in the CLI section.
Trinity Config¶
-
class
trinity.config.TrinityConfig(network_id: int, app_identifier: str = '', genesis_config: Dict[str, Any] = None, max_peers: int = 25, trinity_root_dir: pathlib.Path = None, trinity_tmp_root_dir: bool = False, data_dir: pathlib.Path = None, nodekey_path: pathlib.Path = None, nodekey: eth_keys.datatypes.PrivateKey = None, port: int = 30303, preferred_nodes: Tuple[p2p.kademlia.Node, ...] = None, bootstrap_nodes: Tuple[p2p.kademlia.Node, ...] = None)¶ The
TrinityConfigholds all base configurations that are generic enough to be shared across the different runtime modes that are available. It also gives access to the more specific application configurations derived fromBaseAppConfig.This API is exposed to
BaseComponent-
add_app_config(app_config: trinity.config.BaseAppConfig) → None¶ Register the given
app_config.
-
classmethod
from_parser_args(parser_args: argparse.Namespace, app_identifier: str, app_config_types: Iterable[Type[BaseAppConfig]]) → trinity.config.TrinityConfig¶ Initialize a
TrinityConfigfrom the namespace object produced by anArgumentParser.
-
get_app_config(app_config_type: Type[TAppConfig]) → TAppConfig¶ Return the registered
BaseAppConfiginstance that matches the givenapp_config_type.
-
has_app_config(app_config_type: Type[BaseAppConfig]) → bool¶ Check if a
BaseAppConfiginstance exists that matches the givenapp_config_type.
-
initialize_app_configs(parser_args: argparse.Namespace, app_config_types: Iterable[Type[BaseAppConfig]]) → None¶ Initialize
BaseAppConfiginstances for the passedapp_config_typesbased on theparser_argsand the existingTrintiyConfiginstance.
-
process_id_file(process_name: str)¶ Context manager API to generate process identification files (pid) in the current
pid_dir().trinity_config.process_id_file('networking'): ... # pid file sitting in pid directory while process is running ... # pid file cleaned up
-
with_app_suffix(path: pathlib.Path) → pathlib.Path¶ Return a
Paththat matches the givenpathplus theapp_suffix()
-
app_suffix¶ Return the suffix that Trinity uses to derive various application directories depending on the current mode of operation (e.g.
eth1to derive<trinity-root-dir>/mainnet/logs-eth1)
-
data_dir¶ The data_dir is the base directory that all chain specific information for a given chain is stored.
All defaults for chain directories are resolved relative to this directory.
-
database_ipc_path¶ Return the path for the database IPC socket connection.
-
enr_db_dir¶ Return the directory for the Node database.
-
ipc_dir¶ Return the base directory for all open IPC files.
-
jsonrpc_ipc_path¶ Return the path for the JSON-RPC server IPC socket.
-
log_dir¶ Return the path of the directory where all log files are stored.
-
logfile_path¶ Return the path to the log file.
-
logging_ipc_path¶ Return the path for the logging IPC socket connection.
-
nodekey¶ The
PrivateKeywhich trinity uses to derive the public key needed to identify itself on the network.
-
nodekey_path¶ Path where the nodekey is stored
-
pid_dir¶ Return the base directory for all PID files.
-
trinity_root_dir¶ Base directory that all trinity data is stored under.
The default
data_dirpath will be resolved relative to this directory.
-
Base App Config¶
-
class
trinity.config.BaseAppConfig(trinity_config: trinity.config.TrinityConfig)¶ -
classmethod
from_parser_args(args: argparse.Namespace, trinity_config: trinity.config.TrinityConfig) → trinity.config.BaseAppConfig¶ Initialize from the namespace object produced by an
argparse.ArgumentParserand theTrinityConfig
-
classmethod
Eth1 App Config¶
-
class
trinity.config.Eth1AppConfig(trinity_config: trinity.config.TrinityConfig, sync_mode: str)¶ -
classmethod
from_parser_args(args: argparse.Namespace, trinity_config: trinity.config.TrinityConfig) → trinity.config.BaseAppConfig¶ Initialize from the namespace object produced by an
argparse.ArgumentParserand theTrinityConfig
-
get_chain_config() → trinity.config.Eth1ChainConfig¶ Return the
Eth1ChainConfigeither derived from thenetwork_idor a custom genesis file.
-
database_dir¶ Path where the chain database is stored.
This is resolved relative to the
data_dir
-
database_mode¶ Return the
Eth1DbModefor the currently used database
-
node_class¶ Return the
Nodeclass that trinity uses.
-
sync_mode¶ Return the currently used sync mode
-
classmethod