[][src]Crate tari_common

Common logging and configuration utilities

The global Tari configuration file

A single configuration file (usually ~/.tari/config.toml is used to manage settings for all Tari applications and nodes running on a single system, whether it's a base node, validator node, or wallet.

Setting of configuration parameters is applied using the following order of precedence:

  1. Command-line argument
  2. Environment variable
  3. config.toml file value
  4. Configuration default

The utilities exposed in this crate are opinionated, but flexible. In general, all data is stored in a .tari folder under your home folder.

Example - Loading and deserializing the global config file

This code runs with edition 2018
let config = default_config();
let config = GlobalConfig::convert_from(config).unwrap();
assert_eq!(config.network, Network::MainNet);
assert_eq!(config.blocking_threads, 4);

Modules

dir_utils
protobuf_build

Macros

log_if_error

Log an error if an Err is returned from the $expr. If the given expression is Ok(v), Some(v) is returned, otherwise None is returned (same as Result::ok). Useful in cases where the error should be logged and ignored. instead of writing if let Err(err) = my_error_call() { error!(...) }, you can write log_if_error!(my_error_call())

log_if_error_fmt

See log_if_error!.

Structs

ConfigBootstrap

A minimal parsed configuration object that's used to bootstrap the main Configuration.

ConfigurationError
GlobalConfig

Enums

CommsTransport
DatabaseType
Network
SocksAuthentication
TorControlAuthentication

Constants

DEFAULT_CONFIG
DEFAULT_LOG_CONFIG

Traits

ConfigExtractor

Extract parts of the global Config file into custom configuration objects that are more specific and localised. The expected use case for this is to use load_configuration to load the global configuration file into a Config object. This is then used to generate other, localised configuration objects, for example, MempoolConfig etc.

Functions

bootstrap_config_from_cli
default_config

Generate the global Tari configuration instance.

initialize_logging

Set up application-level logging using the Log4rs configuration file specified in

install_configuration
install_default_config_file

Installs a new configuration file template, copied from tari_config_sample.toml to the given path. When bundled as a binary, the config sample file must be bundled in ./config.

load_configuration