Skip to main content

Crate tari_common

Crate tari_common 

Source
Expand description

§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 (see details: configuration)
  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.

§Custom application configuration

Tari configuration file allows adding custom application specific sections. Tari is using config crate to load configurations and gives access to config::Config struct so that apps might be flexible. Though as tari apps follow certain configurability assumptions, tari_common provides helper traits which automate those with minimal code.

§CLI helpers

Bootstrapping tari configuration files might be customized via CLI or env settings. To help with building tari-enabled CLI from scratch as easy as possible this crate exposes [ConfigBootstrap] struct which implements structopt::StructOpt trait and can be easily reused in any CLI.

Re-exports§

pub use configuration::bootstrap::install_configuration;
pub use configuration::error::ConfigError;
pub use configuration::loader::ConfigLoader;
pub use configuration::loader::ConfigPath;
pub use configuration::loader::ConfigurationError;
pub use configuration::loader::DefaultConfigLoader;
pub use configuration::loader::SubConfigPath;
pub use configuration::name_server::DnsNameServer;
pub use configuration::utils::load_configuration;

Modules§

configuration
Configuration of tari applications
dir_utils
exit_codes
network_check

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!.

Constants§

DEFAULT_BASE_NODE_LOG_CONFIG
DEFAULT_COLLECTIBLES_LOG_CONFIG
DEFAULT_CONFIG
DEFAULT_MERGE_MINING_PROXY_LOG_CONFIG
DEFAULT_MINER_LOG_CONFIG
DEFAULT_STRATUM_TRANSCODER_LOG_CONFIG
DEFAULT_WALLET_LOG_CONFIG
MAX_GRPC_MESSAGE_SIZE
Maximum gRPC message size for clients and servers: 2MiB (coinbases) + 4MiB (transaction payload) + 2MiB (spare capacity) = 8 MiB

Functions§

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