rippled
Loading...
Searching...
No Matches
Config.cpp
1#include <xrpld/core/Config.h>
2#include <xrpld/core/ConfigSections.h>
3
4#include <xrpl/basics/FileUtilities.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/StringUtilities.h>
7#include <xrpl/basics/contract.h>
8#include <xrpl/beast/core/LexicalCast.h>
9#include <xrpl/json/json_reader.h>
10#include <xrpl/net/HTTPClient.h>
11#include <xrpl/protocol/Feature.h>
12#include <xrpl/protocol/SystemParameters.h>
13
14#include <boost/algorithm/string.hpp>
15#include <boost/format.hpp>
16#include <boost/predef.h>
17#include <boost/regex.hpp>
18
19#include <algorithm>
20#include <cstdlib>
21#include <iostream>
22#include <iterator>
23#include <regex>
24#include <thread>
25
26#if BOOST_OS_WINDOWS
27#include <sysinfoapi.h>
28
29namespace xrpl {
30namespace detail {
31
32[[nodiscard]] std::uint64_t
33getMemorySize()
34{
35 if (MEMORYSTATUSEX msx{sizeof(MEMORYSTATUSEX)}; GlobalMemoryStatusEx(&msx))
36 return static_cast<std::uint64_t>(msx.ullTotalPhys);
37
38 return 0;
39}
40
41} // namespace detail
42} // namespace xrpl
43#endif
44
45#if BOOST_OS_LINUX
46#include <sys/sysinfo.h>
47
48namespace xrpl {
49namespace detail {
50
51[[nodiscard]] std::uint64_t
52getMemorySize()
53{
54 if (struct sysinfo si; sysinfo(&si) == 0)
55 return static_cast<std::uint64_t>(si.totalram) * si.mem_unit;
56
57 return 0;
58}
59
60} // namespace detail
61} // namespace xrpl
62
63#endif
64
65#if BOOST_OS_MACOS
66#include <sys/sysctl.h>
67#include <sys/types.h>
68
69namespace xrpl {
70namespace detail {
71
72[[nodiscard]] std::uint64_t
73getMemorySize()
74{
75 int mib[] = {CTL_HW, HW_MEMSIZE};
76 std::int64_t ram = 0;
77 size_t size = sizeof(ram);
78
79 if (sysctl(mib, 2, &ram, &size, NULL, 0) == 0)
80 return static_cast<std::uint64_t>(ram);
81
82 return 0;
83}
84
85} // namespace detail
86} // namespace xrpl
87#endif
88
89namespace xrpl {
90
91// clang-format off
92// The configurable node sizes are "tiny", "small", "medium", "large", "huge"
95{{
96 // FIXME: We should document each of these items, explaining exactly
97 // what they control and whether there exists an explicit
98 // config option that can be used to override the default.
99
100 // tiny small medium large huge
101 {SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
102 {SizedItem::treeCacheSize, {{ 262144, 524288, 2097152, 4194304, 8388608 }}},
103 {SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
104 {SizedItem::ledgerSize, {{ 32, 32, 64, 256, 384 }}},
105 {SizedItem::ledgerAge, {{ 30, 60, 180, 300, 600 }}},
106 {SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
107 {SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
108 {SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
109 {SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
110 {SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
111 {SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
112 {SizedItem::ramSizeGB, {{ 6, 8, 12, 24, 0 }}},
113 {SizedItem::accountIdCacheSize, {{ 20047, 50053, 77081, 150061, 300007 }}}
114}};
115
116// Ensure that the order of entries in the table corresponds to the
117// order of entries in the enum:
118static_assert(
119 []() constexpr->bool {
121
122 for (auto const& i : sizedItems)
123 {
124 if (static_cast<std::underlying_type_t<SizedItem>>(i.first) != idx)
125 return false;
126
127 ++idx;
128 }
129
130 return true;
131 }(),
132 "Mismatch between sized item enum & array indices");
133// clang-format on
134
135//
136// TODO: Check permissions on config file before using it.
137//
138
139#define SECTION_DEFAULT_NAME ""
140
142parseIniFile(std::string const& strInput, bool const bTrim)
143{
144 std::string strData(strInput);
146 IniFileSections secResult;
147
148 // Convert DOS format to unix.
149 boost::algorithm::replace_all(strData, "\r\n", "\n");
150
151 // Convert MacOS format to unix.
152 boost::algorithm::replace_all(strData, "\r", "\n");
153
154 boost::algorithm::split(vLines, strData, boost::algorithm::is_any_of("\n"));
155
156 // Set the default Section name.
157 std::string strSection = SECTION_DEFAULT_NAME;
158
159 // Initialize the default Section.
160 secResult[strSection] = IniFileSections::mapped_type();
161
162 // Parse each line.
163 for (auto& strValue : vLines)
164 {
165 if (bTrim)
166 boost::algorithm::trim(strValue);
167
168 if (strValue.empty() || strValue[0] == '#')
169 {
170 // Blank line or comment, do nothing.
171 }
172 else if (strValue[0] == '[' && strValue[strValue.length() - 1] == ']')
173 {
174 // New Section.
175 strSection = strValue.substr(1, strValue.length() - 2);
176 secResult.emplace(strSection, IniFileSections::mapped_type{});
177 }
178 else
179 {
180 // Another line for Section.
181 if (!strValue.empty())
182 secResult[strSection].push_back(strValue);
183 }
184 }
185
186 return secResult;
187}
188
189IniFileSections::mapped_type*
190getIniFileSection(IniFileSections& secSource, std::string const& strSection)
191{
192 if (auto it = secSource.find(strSection); it != secSource.end())
193 return &(it->second);
194
195 return nullptr;
196}
197
198bool
200 IniFileSections& secSource,
201 std::string const& strSection,
202 std::string& strValue,
204{
205 auto const pmtEntries = getIniFileSection(secSource, strSection);
206
207 if (pmtEntries && pmtEntries->size() == 1)
208 {
209 strValue = (*pmtEntries)[0];
210 return true;
211 }
212
213 if (pmtEntries)
214 {
215 JLOG(j.warn()) << "Section '" << strSection << "': requires 1 line not "
216 << pmtEntries->size() << " lines.";
217 }
218
219 return false;
220}
221
222//------------------------------------------------------------------------------
223//
224// Config
225//
226//------------------------------------------------------------------------------
227
228char const* const Config::configFileName = "xrpld.cfg";
229char const* const Config::configLegacyName = "rippled.cfg";
230char const* const Config::databaseDirName = "db";
231char const* const Config::validatorsFileName = "validators.txt";
232
233[[nodiscard]] static std::string
234getEnvVar(char const* name)
235{
236 std::string value;
237
238 if (auto const v = std::getenv(name); v != nullptr)
239 value = v;
240
241 return value;
242}
243
244Config::Config()
245 : j_(beast::Journal::getNullSink()), ramSize_(detail::getMemorySize() / (1024 * 1024 * 1024))
246{
247}
248
249void
250Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone)
251{
252 XRPL_ASSERT(NODE_SIZE == 0, "xrpl::Config::setupControl : node size not set");
253
254 QUIET = bQuiet || bSilent;
255 SILENT = bSilent;
256 RUN_STANDALONE = bStandalone;
257
258 // We try to autodetect the appropriate node size by checking available
259 // RAM and CPU resources. We default to "tiny" for standalone mode.
260 if (!bStandalone)
261 {
262 // First, check against 'minimum' RAM requirements per node size:
264
265 auto ns = std::find_if(
266 threshold.second.begin(), threshold.second.end(), [this](std::size_t limit) {
267 return (limit == 0) || (ramSize_ < limit);
268 });
269
270 XRPL_ASSERT(ns != threshold.second.end(), "xrpl::Config::setupControl : valid node size");
271
272 if (ns != threshold.second.end())
273 NODE_SIZE = std::distance(threshold.second.begin(), ns);
274
275 // Adjust the size based on the number of hardware threads of
276 // execution available to us:
277 if (auto const hc = std::thread::hardware_concurrency(); hc != 0)
279 }
280
281 XRPL_ASSERT(NODE_SIZE <= 4, "xrpl::Config::setupControl : node size is set");
282}
283
284void
285Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStandalone)
286{
287 setupControl(bQuiet, bSilent, bStandalone);
288
289 // Determine the config and data directories.
290 // If the config file is found in the current working
291 // directory, use the current working directory as the
292 // config directory and that with "db" as the data
293 // directory.
294 boost::filesystem::path dataDir;
295
296 if (!strConf.empty())
297 {
298 // --conf=<path> : everything is relative that file.
299 CONFIG_FILE = strConf;
300 CONFIG_DIR = boost::filesystem::absolute(CONFIG_FILE);
301 CONFIG_DIR.remove_filename();
302 dataDir = CONFIG_DIR / databaseDirName;
303 }
304 else
305 {
306 do
307 {
308 // Check if either of the config files exist in the current working
309 // directory, in which case the databases will be stored in a
310 // subdirectory.
311 CONFIG_DIR = boost::filesystem::current_path();
312 dataDir = CONFIG_DIR / databaseDirName;
314 if (boost::filesystem::exists(CONFIG_FILE))
315 break;
317 if (boost::filesystem::exists(CONFIG_FILE))
318 break;
319
320 // Check if the home directory is set, and optionally the XDG config
321 // and/or data directories, as the config may be there. See
322 // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html.
323 auto const strHome = getEnvVar("HOME");
324 if (!strHome.empty())
325 {
326 auto strXdgConfigHome = getEnvVar("XDG_CONFIG_HOME");
327 auto strXdgDataHome = getEnvVar("XDG_DATA_HOME");
328 if (strXdgConfigHome.empty())
329 {
330 // $XDG_CONFIG_HOME was not set, use default based on $HOME.
331 strXdgConfigHome = strHome + "/.config";
332 }
333 if (strXdgDataHome.empty())
334 {
335 // $XDG_DATA_HOME was not set, use default based on $HOME.
336 strXdgDataHome = strHome + "/.local/share";
337 }
338
339 // Check if either of the config files exist in the XDG config
340 // dir.
341 dataDir = strXdgDataHome + "/" + systemName();
342 CONFIG_DIR = strXdgConfigHome + "/" + systemName();
344 if (boost::filesystem::exists(CONFIG_FILE))
345 break;
347 if (boost::filesystem::exists(CONFIG_FILE))
348 break;
349 }
350
351 // As a last resort, check the system config directory.
352 dataDir = "/var/opt/" + systemName();
353 CONFIG_DIR = "/etc/opt/" + systemName();
355 if (boost::filesystem::exists(CONFIG_FILE))
356 break;
358 } while (false);
359 }
360
361 // Update default values
362 load();
363 {
364 // load() may have set a new value for the dataDir
365 std::string const dbPath(legacy("database_path"));
366 if (!dbPath.empty())
367 dataDir = boost::filesystem::path(dbPath);
368 else if (RUN_STANDALONE)
369 dataDir.clear();
370 }
371
372 if (!dataDir.empty())
373 {
374 boost::system::error_code ec;
375 boost::filesystem::create_directories(dataDir, ec);
376
377 if (ec)
378 Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
379
380 legacy("database_path", boost::filesystem::absolute(dataDir).string());
381 }
382
384 this->SSL_VERIFY_DIR, this->SSL_VERIFY_FILE, this->SSL_VERIFY, j_);
385
386 if (RUN_STANDALONE)
387 LEDGER_HISTORY = 0;
388
389 std::string ledgerTxDbType;
390 Section ledgerTxTablesSection = section("ledger_tx_tables");
391 get_if_exists(ledgerTxTablesSection, "use_tx_tables", USE_TX_TABLES);
392
394 get_if_exists(nodeDbSection, "fast_load", FAST_LOAD);
395}
396
397// 0 ports are allowed for unit tests, but still not allowed to be present in
398// config file
399static void
400checkZeroPorts(Config const& config)
401{
402 if (!config.exists("server"))
403 return;
404
405 for (auto const& name : config.section("server").values())
406 {
407 if (!config.exists(name))
408 return;
409
410 auto const& section = config[name];
411 auto const optResult = section.get("port");
412 if (optResult)
413 {
414 auto const port = beast::lexicalCast<std::uint16_t>(*optResult);
415 if (!port)
416 {
418 ss << "Invalid value '" << *optResult << "' for key 'port' in [" << name << "]";
419 Throw<std::runtime_error>(ss.str());
420 }
421 }
422 }
423}
424
425void
427{
428 // NOTE: this writes to cerr because we want cout to be reserved
429 // for the writing of the json response (so that stdout can be part of a
430 // pipeline, for instance)
431 if (!QUIET)
432 std::cerr << "Loading: " << CONFIG_FILE << "\n";
433
434 boost::system::error_code ec;
435 auto const fileContents = getFileContents(ec, CONFIG_FILE);
436
437 if (ec)
438 {
439 std::cerr << "Failed to read '" << CONFIG_FILE << "'." << ec.value() << ": " << ec.message()
440 << std::endl;
441 return;
442 }
443
444 loadFromString(fileContents);
445 checkZeroPorts(*this);
446}
447
448void
450{
451 IniFileSections secConfig = parseIniFile(fileContents, true);
452
453 build(secConfig);
454
455 if (auto s = getIniFileSection(secConfig, SECTION_IPS))
456 IPS = *s;
457
458 if (auto s = getIniFileSection(secConfig, SECTION_IPS_FIXED))
459 IPS_FIXED = *s;
460
461 // if the user has specified ip:port then replace : with a space.
462 {
463 auto replaceColons = [](std::vector<std::string>& strVec) {
464 static std::regex const e(":([0-9]+)$");
465 for (auto& line : strVec)
466 {
467 // skip anything that might be an ipv6 address
468 if (std::count(line.begin(), line.end(), ':') != 1)
469 continue;
470
471 std::string result = std::regex_replace(line, e, " $1");
472 // sanity check the result of the replace, should be same length
473 // as input
474 if (result.size() == line.size())
475 line = result;
476 }
477 };
478
479 replaceColons(IPS_FIXED);
480 replaceColons(IPS);
481 }
482
483 {
484 std::string dbPath;
485 if (getSingleSection(secConfig, "database_path", dbPath, j_))
486 {
487 boost::filesystem::path p(dbPath);
488 legacy("database_path", boost::filesystem::absolute(p).string());
489 }
490 }
491
492 std::string strTemp;
493
494 if (getSingleSection(secConfig, SECTION_NETWORK_ID, strTemp, j_))
495 {
496 if (strTemp == "main")
497 NETWORK_ID = 0;
498 else if (strTemp == "testnet")
499 NETWORK_ID = 1;
500 else if (strTemp == "devnet")
501 NETWORK_ID = 2;
502 else
503 NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
504 }
505
506 if (getSingleSection(secConfig, SECTION_PEER_PRIVATE, strTemp, j_))
507 PEER_PRIVATE = beast::lexicalCastThrow<bool>(strTemp);
508
509 if (getSingleSection(secConfig, SECTION_PEERS_MAX, strTemp, j_))
510 {
511 PEERS_MAX = beast::lexicalCastThrow<std::size_t>(strTemp);
512 }
513 else
514 {
515 std::optional<std::size_t> peers_in_max{};
516 if (getSingleSection(secConfig, SECTION_PEERS_IN_MAX, strTemp, j_))
517 {
518 peers_in_max = beast::lexicalCastThrow<std::size_t>(strTemp);
519 if (*peers_in_max > 1000)
520 Throw<std::runtime_error>("Invalid value specified in [" SECTION_PEERS_IN_MAX
521 "] section; the value must be less or equal than 1000");
522 }
523
524 std::optional<std::size_t> peers_out_max{};
525 if (getSingleSection(secConfig, SECTION_PEERS_OUT_MAX, strTemp, j_))
526 {
527 peers_out_max = beast::lexicalCastThrow<std::size_t>(strTemp);
528 if (*peers_out_max < 10 || *peers_out_max > 1000)
529 Throw<std::runtime_error>("Invalid value specified in [" SECTION_PEERS_OUT_MAX
530 "] section; the value must be in range 10-1000");
531 }
532
533 // if one section is configured then the other must be configured too
534 if ((peers_in_max && !peers_out_max) || (peers_out_max && !peers_in_max))
535 Throw<std::runtime_error>("Both sections [" SECTION_PEERS_IN_MAX
536 "]"
537 "and [" SECTION_PEERS_OUT_MAX "] must be configured");
538
539 if (peers_in_max && peers_out_max)
540 {
541 PEERS_IN_MAX = *peers_in_max;
542 PEERS_OUT_MAX = *peers_out_max;
543 }
544 }
545
546 if (getSingleSection(secConfig, SECTION_NODE_SIZE, strTemp, j_))
547 {
548 if (boost::iequals(strTemp, "tiny"))
549 NODE_SIZE = 0;
550 else if (boost::iequals(strTemp, "small"))
551 NODE_SIZE = 1;
552 else if (boost::iequals(strTemp, "medium"))
553 NODE_SIZE = 2;
554 else if (boost::iequals(strTemp, "large"))
555 NODE_SIZE = 3;
556 else if (boost::iequals(strTemp, "huge"))
557 NODE_SIZE = 4;
558 else
559 NODE_SIZE = std::min<std::size_t>(4, beast::lexicalCastThrow<std::size_t>(strTemp));
560 }
561
562 if (getSingleSection(secConfig, SECTION_SIGNING_SUPPORT, strTemp, j_))
563 signingEnabled_ = beast::lexicalCastThrow<bool>(strTemp);
564
565 if (getSingleSection(secConfig, SECTION_ELB_SUPPORT, strTemp, j_))
566 ELB_SUPPORT = beast::lexicalCastThrow<bool>(strTemp);
567
568 getSingleSection(secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE, j_);
569 getSingleSection(secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR, j_);
570
571 if (getSingleSection(secConfig, SECTION_SSL_VERIFY, strTemp, j_))
572 SSL_VERIFY = beast::lexicalCastThrow<bool>(strTemp);
573
574 if (getSingleSection(secConfig, SECTION_RELAY_VALIDATIONS, strTemp, j_))
575 {
576 if (boost::iequals(strTemp, "all"))
578 else if (boost::iequals(strTemp, "trusted"))
580 else if (boost::iequals(strTemp, "drop_untrusted"))
582 else
583 Throw<std::runtime_error>("Invalid value specified in [" SECTION_RELAY_VALIDATIONS
584 "] section");
585 }
586
587 if (getSingleSection(secConfig, SECTION_RELAY_PROPOSALS, strTemp, j_))
588 {
589 if (boost::iequals(strTemp, "all"))
591 else if (boost::iequals(strTemp, "trusted"))
593 else if (boost::iequals(strTemp, "drop_untrusted"))
595 else
596 Throw<std::runtime_error>("Invalid value specified in [" SECTION_RELAY_PROPOSALS
597 "] section");
598 }
599
600 if (exists(SECTION_VALIDATION_SEED) && exists(SECTION_VALIDATOR_TOKEN))
601 Throw<std::runtime_error>("Cannot have both [" SECTION_VALIDATION_SEED
602 "] and [" SECTION_VALIDATOR_TOKEN "] config sections");
603
604 if (getSingleSection(secConfig, SECTION_NETWORK_QUORUM, strTemp, j_))
605 NETWORK_QUORUM = beast::lexicalCastThrow<std::size_t>(strTemp);
606
607 FEES = setup_FeeVote(section("voting"));
608 /* [fee_default] is documented in the example config files as useful for
609 * things like offline transaction signing. Until that's completely
610 * deprecated, allow it to override the [voting] section. */
611 if (getSingleSection(secConfig, SECTION_FEE_DEFAULT, strTemp, j_))
612 FEES.reference_fee = beast::lexicalCastThrow<std::uint64_t>(strTemp);
613
614 if (getSingleSection(secConfig, SECTION_LEDGER_HISTORY, strTemp, j_))
615 {
616 if (boost::iequals(strTemp, "full"))
618 else if (boost::iequals(strTemp, "none"))
619 LEDGER_HISTORY = 0;
620 else
621 LEDGER_HISTORY = beast::lexicalCastThrow<std::uint32_t>(strTemp);
622 }
623
624 if (getSingleSection(secConfig, SECTION_FETCH_DEPTH, strTemp, j_))
625 {
626 if (boost::iequals(strTemp, "none"))
627 FETCH_DEPTH = 0;
628 else if (boost::iequals(strTemp, "full"))
629 FETCH_DEPTH = std::numeric_limits<decltype(FETCH_DEPTH)>::max();
630 else
631 FETCH_DEPTH = beast::lexicalCastThrow<std::uint32_t>(strTemp);
632
633 if (FETCH_DEPTH < 10)
634 FETCH_DEPTH = 10;
635 }
636
637 // By default, validators don't have pathfinding enabled, unless it is
638 // explicitly requested by the server's admin.
639 if (exists(SECTION_VALIDATION_SEED) || exists(SECTION_VALIDATOR_TOKEN))
640 PATH_SEARCH_MAX = 0;
641
642 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_OLD, strTemp, j_))
643 PATH_SEARCH_OLD = beast::lexicalCastThrow<int>(strTemp);
644 if (getSingleSection(secConfig, SECTION_PATH_SEARCH, strTemp, j_))
645 PATH_SEARCH = beast::lexicalCastThrow<int>(strTemp);
646 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_FAST, strTemp, j_))
647 PATH_SEARCH_FAST = beast::lexicalCastThrow<int>(strTemp);
648 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_MAX, strTemp, j_))
649 PATH_SEARCH_MAX = beast::lexicalCastThrow<int>(strTemp);
650
651 if (getSingleSection(secConfig, SECTION_DEBUG_LOGFILE, strTemp, j_))
652 DEBUG_LOGFILE = strTemp;
653
654 if (getSingleSection(secConfig, SECTION_SWEEP_INTERVAL, strTemp, j_))
655 {
656 SWEEP_INTERVAL = beast::lexicalCastThrow<std::size_t>(strTemp);
657
658 if (SWEEP_INTERVAL < 10 || SWEEP_INTERVAL > 600)
659 Throw<std::runtime_error>("Invalid " SECTION_SWEEP_INTERVAL
660 ": must be between 10 and 600 inclusive");
661 }
662
663 if (getSingleSection(secConfig, SECTION_WORKERS, strTemp, j_))
664 {
665 WORKERS = beast::lexicalCastThrow<int>(strTemp);
666
667 if (WORKERS < 1 || WORKERS > 1024)
668 Throw<std::runtime_error>("Invalid " SECTION_WORKERS
669 ": must be between 1 and 1024 inclusive.");
670 }
671
672 if (getSingleSection(secConfig, SECTION_IO_WORKERS, strTemp, j_))
673 {
674 IO_WORKERS = beast::lexicalCastThrow<int>(strTemp);
675
676 if (IO_WORKERS < 1 || IO_WORKERS > 1024)
677 Throw<std::runtime_error>("Invalid " SECTION_IO_WORKERS
678 ": must be between 1 and 1024 inclusive.");
679 }
680
681 if (getSingleSection(secConfig, SECTION_PREFETCH_WORKERS, strTemp, j_))
682 {
683 PREFETCH_WORKERS = beast::lexicalCastThrow<int>(strTemp);
684
685 if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024)
686 Throw<std::runtime_error>("Invalid " SECTION_PREFETCH_WORKERS
687 ": must be between 1 and 1024 inclusive.");
688 }
689
690 if (getSingleSection(secConfig, SECTION_COMPRESSION, strTemp, j_))
691 COMPRESSION = beast::lexicalCastThrow<bool>(strTemp);
692
693 if (getSingleSection(secConfig, SECTION_LEDGER_REPLAY, strTemp, j_))
694 LEDGER_REPLAY = beast::lexicalCastThrow<bool>(strTemp);
695
696 if (exists(SECTION_REDUCE_RELAY))
697 {
698 auto sec = section(SECTION_REDUCE_RELAY);
699
701 // vp_enable config option is deprecated by vp_base_squelch_enable //
702 // This option is kept for backwards compatibility. When squelching //
703 // is the default algorithm, it must be replaced with: //
704 // VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = //
705 // sec.value_or("vp_base_squelch_enable", true); //
706 if (sec.exists("vp_base_squelch_enable") && sec.exists("vp_enable"))
707 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
708 " cannot specify both vp_base_squelch_enable and vp_enable "
709 "options. "
710 "vp_enable was deprecated and replaced by "
711 "vp_base_squelch_enable");
712
713 if (sec.exists("vp_base_squelch_enable"))
714 VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.value_or("vp_base_squelch_enable", false);
715 else if (sec.exists("vp_enable"))
716 VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.value_or("vp_enable", false);
717 else
720
722 // Temporary squelching config for the peers selected as a source of //
723 // validator messages. The config must be removed once squelching is //
724 // made the default routing algorithm. //
726 sec.value_or("vp_base_squelch_max_selected_peers", 5);
728 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
729 " vp_base_squelch_max_selected_peers must be "
730 "greater than or equal to 3");
732
733 TX_REDUCE_RELAY_ENABLE = sec.value_or("tx_enable", false);
734 TX_REDUCE_RELAY_METRICS = sec.value_or("tx_metrics", false);
735 TX_REDUCE_RELAY_MIN_PEERS = sec.value_or("tx_min_peers", 20);
736 TX_RELAY_PERCENTAGE = sec.value_or("tx_relay_percentage", 25);
737 if (TX_RELAY_PERCENTAGE < 10 || TX_RELAY_PERCENTAGE > 100 || TX_REDUCE_RELAY_MIN_PEERS < 10)
738 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
739 ", tx_min_peers must be greater than or equal to 10"
740 ", tx_relay_percentage must be greater than or equal to 10 "
741 "and less than or equal to 100");
742 }
743
744 if (getSingleSection(secConfig, SECTION_MAX_TRANSACTIONS, strTemp, j_))
745 {
747 std::clamp(beast::lexicalCastThrow<int>(strTemp), MIN_JOB_QUEUE_TX, MAX_JOB_QUEUE_TX);
748 }
749
750 if (getSingleSection(secConfig, SECTION_SERVER_DOMAIN, strTemp, j_))
751 {
752 if (!isProperlyFormedTomlDomain(strTemp))
753 {
754 Throw<std::runtime_error>(
755 "Invalid " SECTION_SERVER_DOMAIN
756 ": the domain name does not appear to meet the requirements.");
757 }
758
759 SERVER_DOMAIN = strTemp;
760 }
761
762 if (exists(SECTION_OVERLAY))
763 {
764 auto const sec = section(SECTION_OVERLAY);
765
766 using namespace std::chrono;
767
768 try
769 {
770 if (auto val = sec.get("max_unknown_time"))
771 MAX_UNKNOWN_TIME = seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
772 }
773 catch (...)
774 {
775 Throw<std::runtime_error>("Invalid value 'max_unknown_time' in " SECTION_OVERLAY
776 ": must be of the form '<number>' representing seconds.");
777 }
778
779 if (MAX_UNKNOWN_TIME < seconds{300} || MAX_UNKNOWN_TIME > seconds{1800})
780 Throw<std::runtime_error>(
781 "Invalid value 'max_unknown_time' in " SECTION_OVERLAY
782 ": the time must be between 300 and 1800 seconds, inclusive.");
783
784 try
785 {
786 if (auto val = sec.get("max_diverged_time"))
787 MAX_DIVERGED_TIME = seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
788 }
789 catch (...)
790 {
791 Throw<std::runtime_error>("Invalid value 'max_diverged_time' in " SECTION_OVERLAY
792 ": must be of the form '<number>' representing seconds.");
793 }
794
796 {
797 Throw<std::runtime_error>("Invalid value 'max_diverged_time' in " SECTION_OVERLAY
798 ": the time must be between 60 and 900 seconds, inclusive.");
799 }
800 }
801
802 if (getSingleSection(secConfig, SECTION_AMENDMENT_MAJORITY_TIME, strTemp, j_))
803 {
804 using namespace std::chrono;
805 boost::regex const re("^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$");
806 boost::smatch match;
807 if (!boost::regex_match(strTemp, match, re))
808 Throw<std::runtime_error>("Invalid " SECTION_AMENDMENT_MAJORITY_TIME
809 ", must be: [0-9]+ [minutes|hours|days|weeks]");
810
811 std::uint32_t duration = beast::lexicalCastThrow<std::uint32_t>(match[1].str());
812
813 if (boost::iequals(match[2], "minutes"))
815 else if (boost::iequals(match[2], "hours"))
817 else if (boost::iequals(match[2], "days"))
819 else if (boost::iequals(match[2], "weeks"))
821
823 Throw<std::runtime_error>("Invalid " SECTION_AMENDMENT_MAJORITY_TIME
824 ", the minimum amount of time an amendment must hold a "
825 "majority is 15 minutes");
826 }
827
828 if (getSingleSection(secConfig, SECTION_BETA_RPC_API, strTemp, j_))
829 BETA_RPC_API = beast::lexicalCastThrow<bool>(strTemp);
830
831 // Do not load trusted validator configuration for standalone mode
832 if (!RUN_STANDALONE)
833 {
834 // If a file was explicitly specified, then throw if the
835 // path is malformed or if the file does not exist or is
836 // not a file.
837 // If the specified file is not an absolute path, then look
838 // for it in the same directory as the config file.
839 // If no path was specified, then look for validators.txt
840 // in the same directory as the config file, but don't complain
841 // if we can't find it.
842 boost::filesystem::path validatorsFile;
843
844 if (getSingleSection(secConfig, SECTION_VALIDATORS_FILE, strTemp, j_))
845 {
846 validatorsFile = strTemp;
847
848 if (validatorsFile.empty())
849 Throw<std::runtime_error>("Invalid path specified in [" SECTION_VALIDATORS_FILE
850 "]");
851
852 if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty())
853 validatorsFile = CONFIG_DIR / validatorsFile;
854
855 if (!boost::filesystem::exists(validatorsFile))
856 Throw<std::runtime_error>(
857 "The file specified in [" SECTION_VALIDATORS_FILE
858 "] "
859 "does not exist: " +
860 validatorsFile.string());
861
862 else if (
863 !boost::filesystem::is_regular_file(validatorsFile) &&
864 !boost::filesystem::is_symlink(validatorsFile))
865 Throw<std::runtime_error>(
866 "Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " +
867 validatorsFile.string());
868 }
869 else if (!CONFIG_DIR.empty())
870 {
871 validatorsFile = CONFIG_DIR / validatorsFileName;
872
873 if (!validatorsFile.empty())
874 {
875 if (!boost::filesystem::exists(validatorsFile))
876 validatorsFile.clear();
877 else if (
878 !boost::filesystem::is_regular_file(validatorsFile) &&
879 !boost::filesystem::is_symlink(validatorsFile))
880 validatorsFile.clear();
881 }
882 }
883
884 if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
885 (boost::filesystem::is_regular_file(validatorsFile) ||
886 boost::filesystem::is_symlink(validatorsFile)))
887 {
888 boost::system::error_code ec;
889 auto const data = getFileContents(ec, validatorsFile);
890 if (ec)
891 {
892 Throw<std::runtime_error>(
893 "Failed to read '" + validatorsFile.string() + "'." +
894 std::to_string(ec.value()) + ": " + ec.message());
895 }
896
897 auto iniFile = parseIniFile(data, true);
898
899 auto entries = getIniFileSection(iniFile, SECTION_VALIDATORS);
900
901 if (entries)
902 section(SECTION_VALIDATORS).append(*entries);
903
904 auto valKeyEntries = getIniFileSection(iniFile, SECTION_VALIDATOR_KEYS);
905
906 if (valKeyEntries)
907 section(SECTION_VALIDATOR_KEYS).append(*valKeyEntries);
908
909 auto valSiteEntries = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_SITES);
910
911 if (valSiteEntries)
912 section(SECTION_VALIDATOR_LIST_SITES).append(*valSiteEntries);
913
914 auto valListKeys = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_KEYS);
915
916 if (valListKeys)
917 section(SECTION_VALIDATOR_LIST_KEYS).append(*valListKeys);
918
919 auto valListThreshold = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_THRESHOLD);
920
921 if (valListThreshold)
922 section(SECTION_VALIDATOR_LIST_THRESHOLD).append(*valListThreshold);
923
924 if (!entries && !valKeyEntries && !valListKeys)
925 Throw<std::runtime_error>(
926 "The file specified in [" SECTION_VALIDATORS_FILE
927 "] "
928 "does not contain a [" SECTION_VALIDATORS
929 "], "
930 "[" SECTION_VALIDATOR_KEYS
931 "] or "
932 "[" SECTION_VALIDATOR_LIST_KEYS
933 "]"
934 " section: " +
935 validatorsFile.string());
936 }
937
939 auto const& listThreshold = section(SECTION_VALIDATOR_LIST_THRESHOLD);
940 if (listThreshold.lines().empty())
941 return std::nullopt;
942 else if (listThreshold.values().size() == 1)
943 {
944 auto strTemp = listThreshold.values()[0];
945 auto const listThreshold = beast::lexicalCastThrow<std::size_t>(strTemp);
946 if (listThreshold == 0)
947 return std::nullopt; // NOTE: Explicitly ask for computed
948 else if (listThreshold > section(SECTION_VALIDATOR_LIST_KEYS).values().size())
949 {
950 Throw<std::runtime_error>(
951 "Value in config section "
952 "[" SECTION_VALIDATOR_LIST_THRESHOLD
953 "] exceeds the number of configured list keys");
954 }
955 return listThreshold;
956 }
957 else
958 {
959 Throw<std::runtime_error>(
960 "Config section "
961 "[" SECTION_VALIDATOR_LIST_THRESHOLD "] should contain single value only");
962 }
963 }();
964
965 // Consolidate [validator_keys] and [validators]
966 section(SECTION_VALIDATORS).append(section(SECTION_VALIDATOR_KEYS).lines());
967
968 if (!section(SECTION_VALIDATOR_LIST_SITES).lines().empty() &&
969 section(SECTION_VALIDATOR_LIST_KEYS).lines().empty())
970 {
971 Throw<std::runtime_error>(
972 "[" + std::string(SECTION_VALIDATOR_LIST_KEYS) + "] config section is missing");
973 }
974 }
975
976 {
977 auto const part = section("features");
978 for (auto const& s : part.values())
979 {
980 if (auto const f = getRegisteredFeature(s))
981 features.insert(*f);
982 else
983 Throw<std::runtime_error>("Unknown feature: " + s + " in config file.");
984 }
985 }
986
987 // This doesn't properly belong here, but check to make sure that the
988 // value specified for network_quorum is achievable:
989 {
990 auto pm = PEERS_MAX;
991
992 // FIXME this apparently magic value is actually defined as a constant
993 // elsewhere (see defaultMaxPeers) but we handle this check here.
994 if (pm == 0)
995 pm = 21;
996
997 if (NETWORK_QUORUM > pm)
998 {
999 Throw<std::runtime_error>(
1000 "The minimum number of required peers (network_quorum) exceeds "
1001 "the maximum number of allowed peers (peers_max)");
1002 }
1003 }
1004}
1005
1006boost::filesystem::path
1008{
1009 auto log_file = DEBUG_LOGFILE;
1010
1011 if (!log_file.empty() && !log_file.is_absolute())
1012 {
1013 // Unless an absolute path for the log file is specified, the
1014 // path is relative to the config file directory.
1015 log_file = boost::filesystem::absolute(log_file, CONFIG_DIR);
1016 }
1017
1018 if (!log_file.empty())
1019 {
1020 auto log_dir = log_file.parent_path();
1021
1022 if (!boost::filesystem::is_directory(log_dir))
1023 {
1024 boost::system::error_code ec;
1025 boost::filesystem::create_directories(log_dir, ec);
1026
1027 // If we fail, we warn but continue so that the calling code can
1028 // decide how to handle this situation.
1029 if (ec)
1030 {
1031 std::cerr << "Unable to create log file path " << log_dir << ": " << ec.message()
1032 << '\n';
1033 }
1034 }
1035 }
1036
1037 return log_file;
1038}
1039
1040int
1042{
1043 auto const index = static_cast<std::underlying_type_t<SizedItem>>(item);
1044 XRPL_ASSERT(index < sizedItems.size(), "xrpl::Config::getValueFor : valid index input");
1045 XRPL_ASSERT(!node || *node <= 4, "xrpl::Config::getValueFor : unset or valid node");
1046 return sizedItems.at(index).second.at(node.value_or(NODE_SIZE));
1047}
1048
1050setup_FeeVote(Section const& section)
1051{
1052 FeeSetup setup;
1053 {
1054 std::uint64_t temp;
1055 if (set(temp, "reference_fee", section) &&
1057 setup.reference_fee = temp;
1058 }
1059 {
1060 std::uint32_t temp;
1061 if (set(temp, "account_reserve", section))
1062 setup.account_reserve = temp;
1063 if (set(temp, "owner_reserve", section))
1064 setup.owner_reserve = temp;
1065 }
1066 return setup;
1067}
1068
1069DatabaseCon::Setup
1071{
1072 DatabaseCon::Setup setup;
1073
1074 setup.startUp = c.START_UP;
1075 setup.standAlone = c.standalone();
1076 setup.dataDir = c.legacy("database_path");
1077 if (!setup.standAlone && setup.dataDir.empty())
1078 {
1079 Throw<std::runtime_error>("database_path must be set.");
1080 }
1081
1082 if (!setup.globalPragma)
1083 {
1084 auto const& sqlite = c.section("sqlite");
1086 result->reserve(3);
1087
1088 // defaults
1089 std::string safety_level;
1090 std::string journal_mode = "wal";
1091 std::string synchronous = "normal";
1092 std::string temp_store = "file";
1093 bool showRiskWarning = false;
1094
1095 if (set(safety_level, "safety_level", sqlite))
1096 {
1097 if (boost::iequals(safety_level, "low"))
1098 {
1099 // low safety defaults
1100 journal_mode = "memory";
1101 synchronous = "off";
1102 temp_store = "memory";
1103 showRiskWarning = true;
1104 }
1105 else if (!boost::iequals(safety_level, "high"))
1106 {
1107 Throw<std::runtime_error>("Invalid safety_level value: " + safety_level);
1108 }
1109 }
1110
1111 {
1112 // #journal_mode Valid values : delete, truncate, persist,
1113 // memory, wal, off
1114 if (set(journal_mode, "journal_mode", sqlite) && !safety_level.empty())
1115 {
1116 Throw<std::runtime_error>(
1117 "Configuration file may not define both "
1118 "\"safety_level\" and \"journal_mode\"");
1119 }
1120 bool higherRisk =
1121 boost::iequals(journal_mode, "memory") || boost::iequals(journal_mode, "off");
1122 showRiskWarning = showRiskWarning || higherRisk;
1123 if (higherRisk || boost::iequals(journal_mode, "delete") ||
1124 boost::iequals(journal_mode, "truncate") ||
1125 boost::iequals(journal_mode, "persist") || boost::iequals(journal_mode, "wal"))
1126 {
1127 result->emplace_back(
1128 boost::str(boost::format(CommonDBPragmaJournal) % journal_mode));
1129 }
1130 else
1131 {
1132 Throw<std::runtime_error>("Invalid journal_mode value: " + journal_mode);
1133 }
1134 }
1135
1136 {
1137 // #synchronous Valid values : off, normal, full, extra
1138 if (set(synchronous, "synchronous", sqlite) && !safety_level.empty())
1139 {
1140 Throw<std::runtime_error>(
1141 "Configuration file may not define both "
1142 "\"safety_level\" and \"synchronous\"");
1143 }
1144 bool higherRisk = boost::iequals(synchronous, "off");
1145 showRiskWarning = showRiskWarning || higherRisk;
1146 if (higherRisk || boost::iequals(synchronous, "normal") ||
1147 boost::iequals(synchronous, "full") || boost::iequals(synchronous, "extra"))
1148 {
1149 result->emplace_back(boost::str(boost::format(CommonDBPragmaSync) % synchronous));
1150 }
1151 else
1152 {
1153 Throw<std::runtime_error>("Invalid synchronous value: " + synchronous);
1154 }
1155 }
1156
1157 {
1158 // #temp_store Valid values : default, file, memory
1159 if (set(temp_store, "temp_store", sqlite) && !safety_level.empty())
1160 {
1161 Throw<std::runtime_error>(
1162 "Configuration file may not define both "
1163 "\"safety_level\" and \"temp_store\"");
1164 }
1165 bool higherRisk = boost::iequals(temp_store, "memory");
1166 showRiskWarning = showRiskWarning || higherRisk;
1167 if (higherRisk || boost::iequals(temp_store, "default") ||
1168 boost::iequals(temp_store, "file"))
1169 {
1170 result->emplace_back(boost::str(boost::format(CommonDBPragmaTemp) % temp_store));
1171 }
1172 else
1173 {
1174 Throw<std::runtime_error>("Invalid temp_store value: " + temp_store);
1175 }
1176 }
1177
1178 if (showRiskWarning && j && c.LEDGER_HISTORY > SQLITE_TUNING_CUTOFF)
1179 {
1180 JLOG(j->warn()) << "reducing the data integrity guarantees from the "
1181 "default [sqlite] behavior is not recommended for "
1182 "nodes storing large amounts of history, because of the "
1183 "difficulty inherent in rebuilding corrupted data.";
1184 }
1185 XRPL_ASSERT(
1186 result->size() == 3, "xrpl::setup_DatabaseCon::globalPragma : result size is 3");
1187 setup.globalPragma = std::move(result);
1188 }
1189 setup.useGlobalPragma = true;
1190
1191 auto setPragma = [](std::string& pragma, std::string const& key, int64_t value) {
1192 pragma = "PRAGMA " + key + "=" + std::to_string(value) + ";";
1193 };
1194
1195 // Lgr Pragma
1196 setPragma(setup.lgrPragma[0], "journal_size_limit", 1582080);
1197
1198 // TX Pragma
1199 int64_t page_size = 4096;
1200 int64_t journal_size_limit = 1582080;
1201 if (c.exists("sqlite"))
1202 {
1203 auto& s = c.section("sqlite");
1204 set(journal_size_limit, "journal_size_limit", s);
1205 set(page_size, "page_size", s);
1206 if (page_size < 512 || page_size > 65536)
1207 Throw<std::runtime_error>("Invalid page_size. Must be between 512 and 65536.");
1208
1209 if (page_size & (page_size - 1))
1210 Throw<std::runtime_error>("Invalid page_size. Must be a power of 2.");
1211 }
1212
1213 setPragma(setup.txPragma[0], "page_size", page_size);
1214 setPragma(setup.txPragma[1], "journal_size_limit", journal_size_limit);
1215 setPragma(setup.txPragma[2], "max_page_count", 4294967294);
1216 setPragma(setup.txPragma[3], "mmap_size", 17179869184);
1217
1218 return setup;
1219}
1220} // namespace xrpl
T clamp(T... args)
A generic endpoint for log messages.
Definition Journal.h:40
Stream warn() const
Definition Journal.h:313
void build(IniFileSections const &ifs)
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
void legacy(std::string const &section, std::string value)
Set a value that is not a key/value pair.
Section & section(std::string const &name)
Returns the section with the given name.
uint32_t NETWORK_ID
Definition Config.h:138
std::unordered_set< uint256, beast::uhash<> > features
Definition Config.h:257
bool ELB_SUPPORT
Definition Config.h:121
bool COMPRESSION
Definition Config.h:201
static char const *const configLegacyName
Definition Config.h:72
boost::filesystem::path DEBUG_LOGFILE
Definition Config.h:87
void load()
Definition Config.cpp:426
StartUpType START_UP
Definition Config.h:129
std::optional< std::size_t > VALIDATOR_LIST_THRESHOLD
Definition Config.h:280
boost::filesystem::path CONFIG_FILE
Definition Config.h:81
bool TX_REDUCE_RELAY_ENABLE
Definition Config.h:239
static char const *const configFileName
Definition Config.h:71
int MAX_TRANSACTIONS
Definition Config.h:207
std::size_t PEERS_IN_MAX
Definition Config.h:163
int PATH_SEARCH_MAX
Definition Config.h:180
int PATH_SEARCH_OLD
Definition Config.h:177
bool BETA_RPC_API
Definition Config.h:268
std::chrono::seconds MAX_DIVERGED_TIME
Definition Config.h:265
beast::Journal const j_
Definition Config.h:91
std::vector< std::string > IPS
Definition Config.h:124
bool standalone() const
Definition Config.h:312
bool RUN_STANDALONE
Operate in stand-alone mode.
Definition Config.h:104
int PATH_SEARCH_FAST
Definition Config.h:179
std::string SSL_VERIFY_FILE
Definition Config.h:197
std::size_t PEERS_OUT_MAX
Definition Config.h:162
std::string SERVER_DOMAIN
Definition Config.h:259
int RELAY_UNTRUSTED_VALIDATIONS
Definition Config.h:151
bool SILENT
Definition Config.h:94
std::string SSL_VERIFY_DIR
Definition Config.h:198
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
Definition Config.cpp:285
bool USE_TX_TABLES
Definition Config.h:106
static constexpr int MAX_JOB_QUEUE_TX
Definition Config.h:208
int PREFETCH_WORKERS
Definition Config.h:217
std::size_t TX_RELAY_PERCENTAGE
Definition Config.h:252
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition Config.cpp:449
bool SSL_VERIFY
Definition Config.h:196
boost::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
Definition Config.cpp:1007
bool QUIET
Definition Config.h:93
bool TX_REDUCE_RELAY_METRICS
Definition Config.h:246
std::chrono::seconds MAX_UNKNOWN_TIME
Definition Config.h:262
static constexpr int MIN_JOB_QUEUE_TX
Definition Config.h:209
bool PEER_PRIVATE
Definition Config.h:155
static char const *const validatorsFileName
Definition Config.h:74
std::uint32_t LEDGER_HISTORY
Definition Config.h:188
std::size_t NODE_SIZE
Definition Config.h:194
bool FAST_LOAD
Definition Config.h:271
std::size_t PEERS_MAX
Definition Config.h:161
std::uint32_t FETCH_DEPTH
Definition Config.h:189
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
Definition Config.h:114
int PATH_SEARCH
Definition Config.h:178
std::optional< int > SWEEP_INTERVAL
Definition Config.h:224
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
Definition Config.cpp:250
std::size_t NETWORK_QUORUM
Definition Config.h:146
FeeSetup FEES
Definition Config.h:185
int getValueFor(SizedItem item, std::optional< std::size_t > node=std::nullopt) const
Retrieve the default value for the item at the specified node size.
Definition Config.cpp:1041
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition Config.h:229
int IO_WORKERS
Definition Config.h:216
std::vector< std::string > IPS_FIXED
Definition Config.h:127
std::chrono::seconds AMENDMENT_MAJORITY_TIME
Definition Config.h:212
int RELAY_UNTRUSTED_PROPOSALS
Definition Config.h:152
std::size_t VP_REDUCE_RELAY_SQUELCH_MAX_SELECTED_PEERS
Definition Config.h:235
int WORKERS
Definition Config.h:215
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition Config.h:249
boost::filesystem::path CONFIG_DIR
Definition Config.h:84
bool LEDGER_REPLAY
Definition Config.h:204
static char const *const databaseDirName
Definition Config.h:73
static void initializeSSLContext(std::string const &sslVerifyDir, std::string const &sslVerifyFile, bool sslVerify, beast::Journal j)
Holds a collection of configuration values.
Definition BasicConfig.h:24
std::vector< std::string > const & values() const
Returns all the values in the section.
Definition BasicConfig.h:58
void append(std::vector< std::string > const &lines)
Append a set of lines to this section.
T count(T... args)
T distance(T... args)
T emplace(T... args)
T empty(T... args)
T end(T... args)
T endl(T... args)
T find(T... args)
T getenv(T... args)
T hardware_concurrency(T... args)
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::string getFileContents(boost::system::error_code &ec, boost::filesystem::path const &sourcePath, std::optional< std::size_t > maxSize=std::nullopt)
bool isProperlyFormedTomlDomain(std::string_view domain)
Determines if the given string looks like a TOML-file hosting domain.
static std::string getEnvVar(char const *name)
Definition Config.cpp:234
bool getSingleSection(IniFileSections &secSource, std::string const &strSection, std::string &strValue, beast::Journal j)
Definition Config.cpp:199
IniFileSections::mapped_type * getIniFileSection(IniFileSections &secSource, std::string const &strSection)
Definition Config.cpp:190
IniFileSections parseIniFile(std::string const &strInput, bool const bTrim)
Definition Config.cpp:142
FeeSetup setup_FeeVote(Section const &section)
Definition Config.cpp:1050
std::chrono::duration< int, std::ratio_multiply< days::period, std::ratio< 7 > > > weeks
Definition chrono.h:21
SizedItem
Definition Config.h:26
constexpr std::array< std::pair< SizedItem, std::array< int, 5 > >, 13 > sizedItems
Definition Config.cpp:95
std::unordered_map< std::string, std::vector< std::string > > IniFileSections
Definition BasicConfig.h:16
constexpr char const * CommonDBPragmaTemp
Definition DBInit.h:14
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
Definition Config.cpp:1070
constexpr std::uint32_t SQLITE_TUNING_CUTOFF
Definition DBInit.h:20
static std::string const & systemName()
std::chrono::duration< int, std::ratio_multiply< std::chrono::hours::period, std::ratio< 24 > > > days
Definition chrono.h:19
bool get_if_exists(Section const &section, std::string const &name, T &v)
static void checkZeroPorts(Config const &config)
Definition Config.cpp:400
constexpr char const * CommonDBPragmaSync
Definition DBInit.h:13
std::optional< uint256 > getRegisteredFeature(std::string const &name)
Definition Feature.cpp:342
constexpr char const * CommonDBPragmaJournal
Definition DBInit.h:12
T regex_replace(T... args)
T size(T... args)
T str(T... args)
static std::string nodeDatabase()
std::array< std::string, 4 > txPragma
Definition DatabaseCon.h:90
static std::unique_ptr< std::vector< std::string > const > globalPragma
Definition DatabaseCon.h:89
boost::filesystem::path dataDir
Definition DatabaseCon.h:74
std::array< std::string, 1 > lgrPragma
Definition DatabaseCon.h:91
Fee schedule for startup / standalone, and to vote for.
Definition Config.h:48
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition Config.h:50
XRPAmount account_reserve
The account reserve requirement in drops.
Definition Config.h:53
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
Definition Config.h:56
T substr(T... args)
T to_string(T... args)
T value_or(T... args)