#wallet #database #config #common #node #base #tari

tari_common

Utilities and features for the Tari domain layer, shared across both Base and Digital Asset layers

12 unstable releases (3 breaking)

0.8.1 Jan 29, 2021
0.2.7 Oct 12, 2020
0.2.5 Sep 1, 2020
0.2.0 Jul 15, 2020
0.0.5 Sep 2, 2019

#13 in #tari

Download history 49/week @ 2023-07-18 70/week @ 2023-07-25 20/week @ 2023-08-01 33/week @ 2023-08-08 54/week @ 2023-08-15 144/week @ 2023-08-22 33/week @ 2023-08-29 49/week @ 2023-09-05 33/week @ 2023-09-12 33/week @ 2023-09-19 38/week @ 2023-09-26 35/week @ 2023-10-03 25/week @ 2023-10-10 44/week @ 2023-10-17 39/week @ 2023-10-24 50/week @ 2023-10-31

165 downloads per month
Used in 9 crates (5 directly)

BSD-3-Clause

180KB
3K SLoC

Tari Common

This crate provides commonly-used features that are shared across multiple Tari domain layers. Since they may refer to domain-level concepts, it's inappropriate to place them inside the infrastructure folder, tari-utilities specifically.


lib.rs:

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.

Example - CLI which is loading and deserializing the global config file

let mut args = ConfigBootstrap::from_args();
args.init_dirs(ApplicationType::BaseNode);
let config = args.load_configuration().unwrap();
let global = GlobalConfig::convert_from(config).unwrap();
assert_eq!(global.network, Network::Stibbons);
assert!(global.max_threads.is_none());

Dependencies

~12–23MB
~375K SLoC