TARAXA
config.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "common/vrf_wrapper.hpp"
4 #include "config/genesis.hpp"
5 #include "config/network.hpp"
7 
8 namespace taraxa {
9 
10 struct DBConfig {
12  uint32_t db_max_snapshots = 0;
13  uint32_t db_max_open_files = 0;
15  bool rebuild_db = false;
16  bool prune_state_db = false;
17  bool migrate_only = false;
18  bool fix_trx_period = false;
20 };
21 
22 void dec_json(Json::Value const &json, DBConfig &db_config);
23 
25  static constexpr uint64_t kDefaultLightNodeHistoryDays = 7;
26 
27  FullNodeConfig() = default;
28  // The reason of using Json::Value as a union is that in the tests
29  // there are attempts to pass char const* to this constructor, which
30  // is ambiguous (char const* may promote to Json::Value)
31  // if you have std::string and Json::Value constructor. It was easier
32  // to just treat Json::Value as a std::string or Json::Value depending on
33  // the contents
34  explicit FullNodeConfig(const Json::Value &file_name_str_or_json_object, const Json::Value &wallet,
35  const Json::Value &genesis = Json::Value::null, const std::string &config_file_path = "");
36 
37  void overwriteConfigFromJson(const Json::Value &config_json);
38  std::vector<logger::Config> loadLoggingConfigs(const Json::Value &logging);
40  void InitLogging(const addr_t &node_address);
41 
42  std::string json_file_name;
43  std::filesystem::file_time_type last_json_update_time;
46  fs::path data_path;
47  fs::path db_path;
48  fs::path log_path;
53  std::vector<logger::Config> log_configs;
54  bool is_light_node = false; // Is light node
55  uint64_t light_node_history = 0; // Number of periods to keep in history for a light node
56  uint32_t dag_expiry_limit = kDagExpiryLevelLimit; // For unit tests only
57  uint32_t max_levels_per_period = kMaxLevelsPerPeriod; // For unit tests only
58  bool enable_test_rpc = false;
59  bool enable_debug = false;
61 
62  // config values that limits transactions pool
64 
65  // Report malicious behaviour like double voting, etc... to slashing/jailing contract
67 
68  auto net_file_path() const { return data_path / "net"; }
69 
74  void validate() const;
75 };
76 
77 std::ostream &operator<<(std::ostream &strm, NodeConfig const &conf);
78 std::ostream &operator<<(std::ostream &strm, NetworkConfig const &conf);
79 std::ostream &operator<<(std::ostream &strm, FullNodeConfig const &conf);
80 
81 } // namespace taraxa
Definition: FixedHash.h:35
Definition: state_config.hpp:71
Definition: config.hpp:8
constexpr uint32_t kDefaultTransactionPoolSize
Definition: constants.hpp:30
uint32_t db_max_open_files
Definition: config.hpp:13
PbftPeriod db_revert_to_period
Definition: config.hpp:14
bool migrate_only
Definition: config.hpp:17
bool fix_trx_period
Definition: config.hpp:18
void dec_json(Json::Value const &json, DBConfig &db_config)
Definition: config.cpp:13
EthBlockNumber PbftPeriod
Definition: types.hpp:24
std::ostream & operator<<(std::ostream &strm, NodeConfig const &conf)
Definition: config.cpp:205
constexpr uint16_t kMaxLevelsPerPeriod
Definition: constants.hpp:18
bool prune_state_db
Definition: config.hpp:16
PbftPeriod rebuild_db_period
Definition: config.hpp:19
uint32_t db_max_snapshots
Definition: config.hpp:12
constexpr uint32_t kDagExpiryLevelLimit
Definition: constants.hpp:19
uint32_t db_snapshot_each_n_pbft_block
Definition: config.hpp:11
bool rebuild_db
Definition: config.hpp:15
Definition: config.hpp:10
Definition: config.hpp:24
vrf_wrapper::vrf_sk_t vrf_secret
Definition: config.hpp:45
uint32_t transactions_pool_size
Definition: config.hpp:63
dev::Secret node_secret
Definition: config.hpp:44
bool enable_test_rpc
Definition: config.hpp:58
static constexpr uint64_t kDefaultLightNodeHistoryDays
Definition: config.hpp:25
void overwriteConfigFromJson(const Json::Value &config_json)
Definition: config.cpp:70
std::vector< logger::Config > log_configs
Definition: config.hpp:53
std::vector< logger::Config > loadLoggingConfigs(const Json::Value &logging)
Definition: config.cpp:21
bool report_malicious_behaviour
Definition: config.hpp:66
uint32_t dag_expiry_limit
Definition: config.hpp:56
uint32_t max_levels_per_period
Definition: config.hpp:57
fs::path data_path
Definition: config.hpp:46
state_api::Opts opts_final_chain
Definition: config.hpp:52
fs::path log_path
Definition: config.hpp:48
DBConfig db_config
Definition: config.hpp:50
void scheduleLoggingConfigUpdate()
Definition: config.cpp:160
NetworkConfig network
Definition: config.hpp:49
GenesisConfig genesis
Definition: config.hpp:51
uint64_t light_node_history
Definition: config.hpp:55
void validate() const
Validates config values, throws configexception if validation fails.
Definition: config.cpp:194
uint32_t final_chain_cache_in_blocks
Definition: config.hpp:60
std::filesystem::file_time_type last_json_update_time
Definition: config.hpp:43
fs::path db_path
Definition: config.hpp:47
bool is_light_node
Definition: config.hpp:54
std::string json_file_name
Definition: config.hpp:42
auto net_file_path() const
Definition: config.hpp:68
void InitLogging(const addr_t &node_address)
Definition: config.cpp:188
bool enable_debug
Definition: config.hpp:59
Definition: genesis.hpp:23
Definition: network.hpp:65