rippled
Config.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_CORE_CONFIG_H_INCLUDED
21 #define RIPPLE_CORE_CONFIG_H_INCLUDED
22 
23 #include <ripple/basics/BasicConfig.h>
24 #include <ripple/basics/FeeUnits.h>
25 #include <ripple/basics/base_uint.h>
26 #include <ripple/beast/net/IPEndpoint.h>
27 #include <ripple/beast/utility/Journal.h>
28 #include <ripple/protocol/SystemParameters.h> // VFALCO Breaks levelization
29 #include <boost/beast/core/string.hpp>
30 #include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
31 #include <boost/lexical_cast.hpp>
32 #include <boost/optional.hpp>
33 #include <algorithm>
34 #include <cstdint>
35 #include <map>
36 #include <string>
37 #include <type_traits>
38 #include <unordered_set>
39 #include <vector>
40 
41 namespace ripple {
42 
43 class Rules;
44 
45 //------------------------------------------------------------------------------
46 
47 enum class SizedItem : std::size_t {
48  sweepInterval = 0,
51  ledgerSize,
52  ledgerAge,
57  txnDBCache,
59 };
60 
61 // This entire derived class is deprecated.
62 // For new config information use the style implied
63 // in the base class. For existing config information
64 // try to refactor code to use the new style.
65 //
66 class Config : public BasicConfig
67 {
68 public:
69  // Settings related to the configuration file location and directories
70  static char const* const configFileName;
71  static char const* const databaseDirName;
72  static char const* const validatorsFileName;
73 
75  boost::filesystem::path
76  getDebugLogFile() const;
77 
78 private:
79  boost::filesystem::path CONFIG_FILE;
80 
81 public:
82  boost::filesystem::path CONFIG_DIR;
83 
84 private:
85  boost::filesystem::path DEBUG_LOGFILE;
86 
87  void
88  load();
90 
91  bool QUIET = false; // Minimize logging verbosity.
92  bool SILENT = false; // No output to console after startup.
102  bool RUN_STANDALONE = false;
103 
110  bool signingEnabled_ = false;
111 
112 public:
113  bool doImport = false;
114  bool nodeToShard = false;
115  bool validateShards = false;
116  bool ELB_SUPPORT = false;
117 
118  std::vector<std::string> IPS; // Peer IPs from rippled.cfg.
119  std::vector<std::string> IPS_FIXED; // Fixed Peer IPs from rippled.cfg.
120  std::vector<std::string> SNTP_SERVERS; // SNTP servers from rippled.cfg.
121 
124 
125  bool START_VALID = false;
126 
128 
129  // Network parameters
130 
131  // The number of fee units a reference transaction costs
132  static constexpr FeeUnit32 TRANSACTION_FEE_BASE{10};
133 
134  // Note: The following parameters do not relate to the UNL or trust at all
135  // Minimum number of nodes to consider the network present
137 
138  // Peer networking parameters
139 
140  // True to ask peers not to relay current IP.
141  bool PEER_PRIVATE = false;
143 
145 
146  // Path searching
148  int PATH_SEARCH = 7;
150  int PATH_SEARCH_MAX = 10;
151 
152  // Validation
153  boost::optional<std::size_t>
154  VALIDATION_QUORUM; // validations to consider ledger authoritative
155 
159 
160  // Node storage configuration
163 
165 
166  bool SSL_VERIFY = true;
169 
170  // Compression
171  bool COMPRESSION = false;
172 
173  // Thread pool configuration
175 
176  // These override the command line client settings
177  boost::optional<beast::IP::Endpoint> rpc_ip;
178 
180 
181 public:
183  {
184  }
185 
186  /* Be very careful to make sure these bool params
187  are in the right order. */
188  void
189  setup(
190  std::string const& strConf,
191  bool bQuiet,
192  bool bSilent,
193  bool bStandalone);
194  void
195  setupControl(bool bQuiet, bool bSilent, bool bStandalone);
196 
202  void
203  loadFromString(std::string const& fileContents);
204 
205  bool
206  quiet() const
207  {
208  return QUIET;
209  }
210  bool
211  silent() const
212  {
213  return SILENT;
214  }
215  bool
216  standalone() const
217  {
218  return RUN_STANDALONE;
219  }
220 
221  bool
222  canSign() const
223  {
224  return signingEnabled_;
225  }
226 
244  int
245  getValueFor(SizedItem item, boost::optional<std::size_t> node = boost::none)
246  const;
247 };
248 
249 } // namespace ripple
250 
251 #endif
ripple::Config::NORMAL
@ NORMAL
Definition: Config.h:122
std::string
STL class.
ripple::SizedItem
SizedItem
Definition: Config.h:47
ripple::Config::PATH_SEARCH
int PATH_SEARCH
Definition: Config.h:148
ripple::SizedItem::nodeCacheSize
@ nodeCacheSize
unordered_set
ripple::Config::Config
Config()
Definition: Config.h:182
ripple::Config::validatorsFileName
static char const *const validatorsFileName
Definition: Config.h:72
vector
ripple::Config::SSL_VERIFY_DIR
std::string SSL_VERIFY_DIR
Definition: Config.h:168
ripple::Config::getValueFor
int getValueFor(SizedItem item, boost::optional< std::size_t > node=boost::none) const
Retrieve the default value for the item at the specified node size.
Definition: Config.cpp:645
ripple::Config::CONFIG_FILE
boost::filesystem::path CONFIG_FILE
Definition: Config.h:79
std::chrono::seconds
ripple::Config::NODE_SIZE
std::size_t NODE_SIZE
Definition: Config.h:164
ripple::Config::PEER_PRIVATE
bool PEER_PRIVATE
Definition: Config.h:141
ripple::Config::DEBUG_LOGFILE
boost::filesystem::path DEBUG_LOGFILE
Definition: Config.h:85
ripple::Config::silent
bool silent() const
Definition: Config.h:211
ripple::Config::setupControl
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:197
ripple::SizedItem::treeCacheAge
@ treeCacheAge
ripple::Config::LOAD
@ LOAD
Definition: Config.h:122
ripple::Config::StartUpType
StartUpType
Definition: Config.h:122
ripple::SizedItem::nodeCacheAge
@ nodeCacheAge
ripple::SizedItem::hashNodeDBCache
@ hashNodeDBCache
ripple::SizedItem::ledgerFetch
@ ledgerFetch
beast::Journal::getNullSink
static Sink & getNullSink()
Returns a Sink which does nothing.
Definition: beast_Journal.cpp:72
ripple::Config::quiet
bool quiet() const
Definition: Config.h:206
ripple::Config::FETCH_DEPTH
std::uint32_t FETCH_DEPTH
Definition: Config.h:162
algorithm
ripple::Config::PATH_SEARCH_MAX
int PATH_SEARCH_MAX
Definition: Config.h:150
ripple::Config::RUN_STANDALONE
bool RUN_STANDALONE
Operate in stand-alone mode.
Definition: Config.h:102
ripple::Config::load
void load()
Definition: Config.cpp:313
ripple::Config::j_
const beast::Journal j_
Definition: Config.h:89
ripple::Config::SSL_VERIFY_FILE
std::string SSL_VERIFY_FILE
Definition: Config.h:167
ripple::Config::loadFromString
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition: Config.cpp:335
ripple::Config::VALIDATION_QUORUM
boost::optional< std::size_t > VALIDATION_QUORUM
Definition: Config.h:154
ripple::Config
Definition: Config.h:66
ripple::Config::TRANSACTION_FEE_BASE
static constexpr FeeUnit32 TRANSACTION_FEE_BASE
Definition: Config.h:132
ripple::Config::NETWORK
@ NETWORK
Definition: Config.h:122
ripple::Config::SNTP_SERVERS
std::vector< std::string > SNTP_SERVERS
Definition: Config.h:120
ripple::Config::WEBSOCKET_PING_FREQ
std::chrono::seconds WEBSOCKET_PING_FREQ
Definition: Config.h:144
ripple::Config::IPS_FIXED
std::vector< std::string > IPS_FIXED
Definition: Config.h:119
ripple::Config::FEE_OWNER_RESERVE
XRPAmount FEE_OWNER_RESERVE
Definition: Config.h:158
ripple::Config::standalone
bool standalone() const
Definition: Config.h:216
ripple::Config::SSL_VERIFY
bool SSL_VERIFY
Definition: Config.h:166
ripple::Config::FEE_ACCOUNT_RESERVE
XRPAmount FEE_ACCOUNT_RESERVE
Definition: Config.h:157
cstdint
ripple::Config::START_UP
StartUpType START_UP
Definition: Config.h:123
ripple::SizedItem::lgrDBCache
@ lgrDBCache
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::Config::nodeToShard
bool nodeToShard
Definition: Config.h:114
std::uint32_t
ripple::Config::canSign
bool canSign() const
Definition: Config.h:222
ripple::Config::databaseDirName
static char const *const databaseDirName
Definition: Config.h:71
ripple::feeunit::TaggedFee
Definition: FeeUnits.h:70
ripple::Config::START_VALID
bool START_VALID
Definition: Config.h:125
map
ripple::SizedItem::txnDBCache
@ txnDBCache
ripple::Config::WORKERS
std::size_t WORKERS
Definition: Config.h:174
ripple::Config::PATH_SEARCH_OLD
int PATH_SEARCH_OLD
Definition: Config.h:147
ripple::Config::LEDGER_HISTORY
std::uint32_t LEDGER_HISTORY
Definition: Config.h:161
ripple::Config::NETWORK_QUORUM
std::size_t NETWORK_QUORUM
Definition: Config.h:136
ripple::DROPS_PER_XRP
constexpr XRPAmount DROPS_PER_XRP
Number of drops per 1 XRP.
Definition: XRPAmount.h:244
ripple::Config::CONFIG_DIR
boost::filesystem::path CONFIG_DIR
Definition: Config.h:82
ripple::Config::PEERS_MAX
std::size_t PEERS_MAX
Definition: Config.h:142
ripple::Config::FEE_DEFAULT
XRPAmount FEE_DEFAULT
Definition: Config.h:156
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Config::FRESH
@ FRESH
Definition: Config.h:122
ripple::Config::features
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:179
ripple::Config::PATH_SEARCH_FAST
int PATH_SEARCH_FAST
Definition: Config.h:149
ripple::Config::setup
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:205
ripple::SizedItem::treeCacheSize
@ treeCacheSize
ripple::Config::REPLAY
@ REPLAY
Definition: Config.h:122
ripple::Config::doImport
bool doImport
Definition: Config.h:113
ripple::SizedItem::sweepInterval
@ sweepInterval
ripple::Config::COMPRESSION
bool COMPRESSION
Definition: Config.h:171
ripple::SizedItem::ledgerSize
@ ledgerSize
ripple::Config::IPS
std::vector< std::string > IPS
Definition: Config.h:118
ripple::Config::configFileName
static char const *const configFileName
Definition: Config.h:70
std::size_t
ripple::Config::QUIET
bool QUIET
Definition: Config.h:91
ripple::Config::SILENT
bool SILENT
Definition: Config.h:92
ripple::Config::getDebugLogFile
boost::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
Definition: Config.cpp:611
ripple::Config::signingEnabled_
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
Definition: Config.h:110
ripple::Config::LOAD_FILE
@ LOAD_FILE
Definition: Config.h:122
ripple::Config::rpc_ip
boost::optional< beast::IP::Endpoint > rpc_ip
Definition: Config.h:177
ripple::Config::ELB_SUPPORT
bool ELB_SUPPORT
Definition: Config.h:116
type_traits
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:178
ripple::Config::START_LEDGER
std::string START_LEDGER
Definition: Config.h:127
ripple::SizedItem::ledgerAge
@ ledgerAge
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::Config::validateShards
bool validateShards
Definition: Config.h:115
string