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// clang-format on
116
117// Ensure that the order of entries in the table corresponds to the
118// order of entries in the enum:
119static_assert(
120 []() constexpr -> bool {
122
123 for (auto const& i : sizedItems)
124 {
125 if (static_cast<std::underlying_type_t<SizedItem>>(i.first) != idx)
126 return false;
127
128 ++idx;
129 }
130
131 return true;
132 }(),
133 "Mismatch between sized item enum & array indices");
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; // NOLINT(readability-redundant-string-init)
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 != nullptr) && pmtEntries->size() == 1)
208 {
209 strValue = (*pmtEntries)[0];
210 return true;
211 }
212
213 if (pmtEntries != nullptr)
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
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 {
368 dataDir = boost::filesystem::path(dbPath);
369 }
370 else if (RUN_STANDALONE)
371 {
372 dataDir.clear();
373 }
374 }
375
376 if (!dataDir.empty())
377 {
378 boost::system::error_code ec;
379 boost::filesystem::create_directories(dataDir, ec);
380
381 if (ec)
382 Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
383
384 legacy("database_path", boost::filesystem::absolute(dataDir).string());
385 }
386
388 this->SSL_VERIFY_DIR, this->SSL_VERIFY_FILE, this->SSL_VERIFY, j_);
389
390 if (RUN_STANDALONE)
391 LEDGER_HISTORY = 0;
392
393 Section const ledgerTxTablesSection = section("ledger_tx_tables");
394 get_if_exists(ledgerTxTablesSection, "use_tx_tables", USE_TX_TABLES);
395
396 Section const& nodeDbSection{section(ConfigSection::nodeDatabase())};
397 get_if_exists(nodeDbSection, "fast_load", FAST_LOAD);
398}
399
400// 0 ports are allowed for unit tests, but still not allowed to be present in
401// config file
402static void
403checkZeroPorts(Config const& config)
404{
405 if (!config.exists("server"))
406 return;
407
408 for (auto const& name : config.section("server").values())
409 {
410 if (!config.exists(name))
411 return;
412
413 auto const& section = config[name];
414 auto const optResult = section.get("port");
415 if (optResult)
416 {
417 auto const port = beast::lexicalCast<std::uint16_t>(*optResult);
418 if (port == 0u)
419 {
421 ss << "Invalid value '" << *optResult << "' for key 'port' in [" << name << "]";
422 Throw<std::runtime_error>(ss.str());
423 }
424 }
425 }
426}
427
428void
430{
431 // NOTE: this writes to cerr because we want cout to be reserved
432 // for the writing of the json response (so that stdout can be part of a
433 // pipeline, for instance)
434 if (!QUIET)
435 std::cerr << "Loading: " << CONFIG_FILE << "\n";
436
437 boost::system::error_code ec;
438 auto const fileContents = getFileContents(ec, CONFIG_FILE);
439
440 if (ec)
441 {
442 std::cerr << "Failed to read '" << CONFIG_FILE << "'." << ec.value() << ": " << ec.message()
443 << std::endl;
444 return;
445 }
446
447 loadFromString(fileContents);
448 checkZeroPorts(*this);
449}
450
451void
453{
454 IniFileSections secConfig = parseIniFile(fileContents, true);
455
456 build(secConfig);
457
458 if (auto s = getIniFileSection(secConfig, SECTION_IPS))
459 IPS = *s;
460
461 if (auto s = getIniFileSection(secConfig, SECTION_IPS_FIXED))
462 IPS_FIXED = *s;
463
464 // if the user has specified ip:port then replace : with a space.
465 {
466 auto replaceColons = [](std::vector<std::string>& strVec) {
467 static std::regex const e(":([0-9]+)$");
468 for (auto& line : strVec)
469 {
470 // skip anything that might be an ipv6 address
471 if (std::count(line.begin(), line.end(), ':') != 1)
472 continue;
473
474 std::string const result = std::regex_replace(line, e, " $1");
475 // sanity check the result of the replace, should be same length
476 // as input
477 if (result.size() == line.size())
478 line = result;
479 }
480 };
481
482 replaceColons(IPS_FIXED);
483 replaceColons(IPS);
484 }
485
486 {
487 std::string dbPath;
488 if (getSingleSection(secConfig, "database_path", dbPath, j_))
489 {
490 boost::filesystem::path const p(dbPath);
491 legacy("database_path", boost::filesystem::absolute(p).string());
492 }
493 }
494
495 std::string strTemp;
496
497 if (getSingleSection(secConfig, SECTION_NETWORK_ID, strTemp, j_))
498 {
499 if (strTemp == "main")
500 {
501 NETWORK_ID = 0;
502 }
503 else if (strTemp == "testnet")
504 {
505 NETWORK_ID = 1;
506 }
507 else if (strTemp == "devnet")
508 {
509 NETWORK_ID = 2;
510 }
511 else
512 {
513 NETWORK_ID = beast::lexicalCastThrow<uint32_t>(strTemp);
514 }
515 }
516
517 if (getSingleSection(secConfig, SECTION_PEER_PRIVATE, strTemp, j_))
518 PEER_PRIVATE = beast::lexicalCastThrow<bool>(strTemp);
519
520 if (getSingleSection(secConfig, SECTION_PEERS_MAX, strTemp, j_))
521 {
522 PEERS_MAX = beast::lexicalCastThrow<std::size_t>(strTemp);
523 }
524 else
525 {
526 std::optional<std::size_t> peers_in_max{};
527 if (getSingleSection(secConfig, SECTION_PEERS_IN_MAX, strTemp, j_))
528 {
529 peers_in_max = beast::lexicalCastThrow<std::size_t>(strTemp);
530 if (*peers_in_max > 1000)
531 {
532 Throw<std::runtime_error>("Invalid value specified in [" SECTION_PEERS_IN_MAX
533 "] section; the value must be less or equal than 1000");
534 }
535 }
536
537 std::optional<std::size_t> peers_out_max{};
538 if (getSingleSection(secConfig, SECTION_PEERS_OUT_MAX, strTemp, j_))
539 {
540 peers_out_max = beast::lexicalCastThrow<std::size_t>(strTemp);
541 if (*peers_out_max < 10 || *peers_out_max > 1000)
542 {
543 Throw<std::runtime_error>("Invalid value specified in [" SECTION_PEERS_OUT_MAX
544 "] section; the value must be in range 10-1000");
545 }
546 }
547
548 // if one section is configured then the other must be configured too
549 if ((peers_in_max && !peers_out_max) || (peers_out_max && !peers_in_max))
550 {
551 Throw<std::runtime_error>("Both sections [" SECTION_PEERS_IN_MAX
552 "]"
553 "and [" SECTION_PEERS_OUT_MAX "] must be configured");
554 }
555
556 if (peers_in_max && peers_out_max)
557 {
558 PEERS_IN_MAX = *peers_in_max;
559 PEERS_OUT_MAX = *peers_out_max;
560 }
561 }
562
563 if (getSingleSection(secConfig, SECTION_NODE_SIZE, strTemp, j_))
564 {
565 if (boost::iequals(strTemp, "tiny"))
566 {
567 NODE_SIZE = 0;
568 }
569 else if (boost::iequals(strTemp, "small"))
570 {
571 NODE_SIZE = 1;
572 }
573 else if (boost::iequals(strTemp, "medium"))
574 {
575 NODE_SIZE = 2;
576 }
577 else if (boost::iequals(strTemp, "large"))
578 {
579 NODE_SIZE = 3;
580 }
581 else if (boost::iequals(strTemp, "huge"))
582 {
583 NODE_SIZE = 4;
584 }
585 else
586 {
587 NODE_SIZE = std::min<std::size_t>(4, beast::lexicalCastThrow<std::size_t>(strTemp));
588 }
589 }
590
591 if (getSingleSection(secConfig, SECTION_SIGNING_SUPPORT, strTemp, j_))
592 signingEnabled_ = beast::lexicalCastThrow<bool>(strTemp);
593
594 if (getSingleSection(secConfig, SECTION_ELB_SUPPORT, strTemp, j_))
595 ELB_SUPPORT = beast::lexicalCastThrow<bool>(strTemp);
596
597 getSingleSection(secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE, j_);
598 getSingleSection(secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR, j_);
599
600 if (getSingleSection(secConfig, SECTION_SSL_VERIFY, strTemp, j_))
601 SSL_VERIFY = beast::lexicalCastThrow<bool>(strTemp);
602
603 if (getSingleSection(secConfig, SECTION_RELAY_VALIDATIONS, strTemp, j_))
604 {
605 if (boost::iequals(strTemp, "all"))
606 {
608 }
609 else if (boost::iequals(strTemp, "trusted"))
610 {
612 }
613 else if (boost::iequals(strTemp, "drop_untrusted"))
614 {
616 }
617 else
618 {
619 Throw<std::runtime_error>("Invalid value specified in [" SECTION_RELAY_VALIDATIONS
620 "] section");
621 }
622 }
623
624 if (getSingleSection(secConfig, SECTION_RELAY_PROPOSALS, strTemp, j_))
625 {
626 if (boost::iequals(strTemp, "all"))
627 {
629 }
630 else if (boost::iequals(strTemp, "trusted"))
631 {
633 }
634 else if (boost::iequals(strTemp, "drop_untrusted"))
635 {
637 }
638 else
639 {
640 Throw<std::runtime_error>("Invalid value specified in [" SECTION_RELAY_PROPOSALS
641 "] section");
642 }
643 }
644
645 if (exists(SECTION_VALIDATION_SEED) && exists(SECTION_VALIDATOR_TOKEN))
646 {
647 Throw<std::runtime_error>("Cannot have both [" SECTION_VALIDATION_SEED
648 "] and [" SECTION_VALIDATOR_TOKEN "] config sections");
649 }
650
651 if (getSingleSection(secConfig, SECTION_NETWORK_QUORUM, strTemp, j_))
652 NETWORK_QUORUM = beast::lexicalCastThrow<std::size_t>(strTemp);
653
654 FEES = setup_FeeVote(section("voting"));
655 /* [fee_default] is documented in the example config files as useful for
656 * things like offline transaction signing. Until that's completely
657 * deprecated, allow it to override the [voting] section. */
658 if (getSingleSection(secConfig, SECTION_FEE_DEFAULT, strTemp, j_))
659 FEES.reference_fee = beast::lexicalCastThrow<std::uint64_t>(strTemp);
660
661 if (getSingleSection(secConfig, SECTION_LEDGER_HISTORY, strTemp, j_))
662 {
663 if (boost::iequals(strTemp, "full"))
664 {
666 }
667 else if (boost::iequals(strTemp, "none"))
668 {
669 LEDGER_HISTORY = 0;
670 }
671 else
672 {
673 LEDGER_HISTORY = beast::lexicalCastThrow<std::uint32_t>(strTemp);
674 }
675 }
676
677 if (getSingleSection(secConfig, SECTION_FETCH_DEPTH, strTemp, j_))
678 {
679 if (boost::iequals(strTemp, "none"))
680 {
681 FETCH_DEPTH = 0;
682 }
683 else if (boost::iequals(strTemp, "full"))
684 {
685 FETCH_DEPTH = std::numeric_limits<decltype(FETCH_DEPTH)>::max();
686 }
687 else
688 {
689 FETCH_DEPTH = beast::lexicalCastThrow<std::uint32_t>(strTemp);
690 }
691
693 }
694
695 // By default, validators don't have pathfinding enabled, unless it is
696 // explicitly requested by the server's admin.
697 if (exists(SECTION_VALIDATION_SEED) || exists(SECTION_VALIDATOR_TOKEN))
698 PATH_SEARCH_MAX = 0;
699
700 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_OLD, strTemp, j_))
701 PATH_SEARCH_OLD = beast::lexicalCastThrow<int>(strTemp);
702 if (getSingleSection(secConfig, SECTION_PATH_SEARCH, strTemp, j_))
703 PATH_SEARCH = beast::lexicalCastThrow<int>(strTemp);
704 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_FAST, strTemp, j_))
705 PATH_SEARCH_FAST = beast::lexicalCastThrow<int>(strTemp);
706 if (getSingleSection(secConfig, SECTION_PATH_SEARCH_MAX, strTemp, j_))
707 PATH_SEARCH_MAX = beast::lexicalCastThrow<int>(strTemp);
708
709 if (getSingleSection(secConfig, SECTION_DEBUG_LOGFILE, strTemp, j_))
710 DEBUG_LOGFILE = strTemp;
711
712 if (getSingleSection(secConfig, SECTION_SWEEP_INTERVAL, strTemp, j_))
713 {
714 SWEEP_INTERVAL = beast::lexicalCastThrow<std::size_t>(strTemp);
715
716 if (SWEEP_INTERVAL < 10 || SWEEP_INTERVAL > 600)
717 {
718 Throw<std::runtime_error>("Invalid " SECTION_SWEEP_INTERVAL
719 ": must be between 10 and 600 inclusive");
720 }
721 }
722
723 if (getSingleSection(secConfig, SECTION_WORKERS, strTemp, j_))
724 {
725 WORKERS = beast::lexicalCastThrow<int>(strTemp);
726
727 if (WORKERS < 1 || WORKERS > 1024)
728 {
729 Throw<std::runtime_error>("Invalid " SECTION_WORKERS
730 ": must be between 1 and 1024 inclusive.");
731 }
732 }
733
734 if (getSingleSection(secConfig, SECTION_IO_WORKERS, strTemp, j_))
735 {
736 IO_WORKERS = beast::lexicalCastThrow<int>(strTemp);
737
738 if (IO_WORKERS < 1 || IO_WORKERS > 1024)
739 {
740 Throw<std::runtime_error>("Invalid " SECTION_IO_WORKERS
741 ": must be between 1 and 1024 inclusive.");
742 }
743 }
744
745 if (getSingleSection(secConfig, SECTION_PREFETCH_WORKERS, strTemp, j_))
746 {
747 PREFETCH_WORKERS = beast::lexicalCastThrow<int>(strTemp);
748
749 if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024)
750 {
751 Throw<std::runtime_error>("Invalid " SECTION_PREFETCH_WORKERS
752 ": must be between 1 and 1024 inclusive.");
753 }
754 }
755
756 if (getSingleSection(secConfig, SECTION_COMPRESSION, strTemp, j_))
757 COMPRESSION = beast::lexicalCastThrow<bool>(strTemp);
758
759 if (getSingleSection(secConfig, SECTION_LEDGER_REPLAY, strTemp, j_))
760 LEDGER_REPLAY = beast::lexicalCastThrow<bool>(strTemp);
761
762 if (exists(SECTION_REDUCE_RELAY))
763 {
764 auto sec = section(SECTION_REDUCE_RELAY);
765
767 // vp_enable config option is deprecated by vp_base_squelch_enable //
768 // This option is kept for backwards compatibility. When squelching //
769 // is the default algorithm, it must be replaced with: //
770 // VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = //
771 // sec.value_or("vp_base_squelch_enable", true); //
772 if (sec.exists("vp_base_squelch_enable") && sec.exists("vp_enable"))
773 {
774 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
775 " cannot specify both vp_base_squelch_enable and vp_enable "
776 "options. "
777 "vp_enable was deprecated and replaced by "
778 "vp_base_squelch_enable");
779 }
780
781 if (sec.exists("vp_base_squelch_enable"))
782 {
783 VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.value_or("vp_base_squelch_enable", false);
784 }
785 else if (sec.exists("vp_enable"))
786 {
787 VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.value_or("vp_enable", false);
788 }
789 else
790 {
792 }
794
796 // Temporary squelching config for the peers selected as a source of //
797 // validator messages. The config must be removed once squelching is //
798 // made the default routing algorithm. //
800 sec.value_or("vp_base_squelch_max_selected_peers", 5);
802 {
803 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
804 " vp_base_squelch_max_selected_peers must be "
805 "greater than or equal to 3");
806 }
808
809 TX_REDUCE_RELAY_ENABLE = sec.value_or("tx_enable", false);
810 TX_REDUCE_RELAY_METRICS = sec.value_or("tx_metrics", false);
811 TX_REDUCE_RELAY_MIN_PEERS = sec.value_or("tx_min_peers", 20);
812 TX_RELAY_PERCENTAGE = sec.value_or("tx_relay_percentage", 25);
813 if (TX_RELAY_PERCENTAGE < 10 || TX_RELAY_PERCENTAGE > 100 || TX_REDUCE_RELAY_MIN_PEERS < 10)
814 {
815 Throw<std::runtime_error>("Invalid " SECTION_REDUCE_RELAY
816 ", tx_min_peers must be greater than or equal to 10"
817 ", tx_relay_percentage must be greater than or equal to 10 "
818 "and less than or equal to 100");
819 }
820 }
821
822 if (getSingleSection(secConfig, SECTION_MAX_TRANSACTIONS, strTemp, j_))
823 {
825 std::clamp(beast::lexicalCastThrow<int>(strTemp), MIN_JOB_QUEUE_TX, MAX_JOB_QUEUE_TX);
826 }
827
828 if (getSingleSection(secConfig, SECTION_SERVER_DOMAIN, strTemp, j_))
829 {
830 if (!isProperlyFormedTomlDomain(strTemp))
831 {
832 Throw<std::runtime_error>(
833 "Invalid " SECTION_SERVER_DOMAIN
834 ": the domain name does not appear to meet the requirements.");
835 }
836
837 SERVER_DOMAIN = strTemp;
838 }
839
840 if (exists(SECTION_OVERLAY))
841 {
842 auto const sec = section(SECTION_OVERLAY);
843
844 using namespace std::chrono;
845
846 try
847 {
848 if (auto val = sec.get("max_unknown_time"))
849 MAX_UNKNOWN_TIME = seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
850 }
851 catch (...)
852 {
853 Throw<std::runtime_error>("Invalid value 'max_unknown_time' in " SECTION_OVERLAY
854 ": must be of the form '<number>' representing seconds.");
855 }
856
857 if (MAX_UNKNOWN_TIME < seconds{300} || MAX_UNKNOWN_TIME > seconds{1800})
858 {
859 Throw<std::runtime_error>(
860 "Invalid value 'max_unknown_time' in " SECTION_OVERLAY
861 ": the time must be between 300 and 1800 seconds, inclusive.");
862 }
863
864 try
865 {
866 if (auto val = sec.get("max_diverged_time"))
867 MAX_DIVERGED_TIME = seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
868 }
869 catch (...)
870 {
871 Throw<std::runtime_error>("Invalid value 'max_diverged_time' in " SECTION_OVERLAY
872 ": must be of the form '<number>' representing seconds.");
873 }
874
876 {
877 Throw<std::runtime_error>("Invalid value 'max_diverged_time' in " SECTION_OVERLAY
878 ": the time must be between 60 and 900 seconds, inclusive.");
879 }
880 }
881
882 if (getSingleSection(secConfig, SECTION_AMENDMENT_MAJORITY_TIME, strTemp, j_))
883 {
884 using namespace std::chrono;
885 boost::regex const re("^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$");
886 boost::smatch match;
887 if (!boost::regex_match(strTemp, match, re))
888 {
889 Throw<std::runtime_error>("Invalid " SECTION_AMENDMENT_MAJORITY_TIME
890 ", must be: [0-9]+ [minutes|hours|days|weeks]");
891 }
892
893 std::uint32_t const duration = beast::lexicalCastThrow<std::uint32_t>(match[1].str());
894
895 if (boost::iequals(match[2], "minutes"))
896 {
898 }
899 else if (boost::iequals(match[2], "hours"))
900 {
902 }
903 else if (boost::iequals(match[2], "days"))
904 {
906 }
907 else if (boost::iequals(match[2], "weeks"))
908 {
910 }
911
913 {
914 Throw<std::runtime_error>("Invalid " SECTION_AMENDMENT_MAJORITY_TIME
915 ", the minimum amount of time an amendment must hold a "
916 "majority is 15 minutes");
917 }
918 }
919
920 if (getSingleSection(secConfig, SECTION_BETA_RPC_API, strTemp, j_))
921 BETA_RPC_API = beast::lexicalCastThrow<bool>(strTemp);
922
923 // Do not load trusted validator configuration for standalone mode
924 if (!RUN_STANDALONE)
925 {
926 // If a file was explicitly specified, then throw if the
927 // path is malformed or if the file does not exist or is
928 // not a file.
929 // If the specified file is not an absolute path, then look
930 // for it in the same directory as the config file.
931 // If no path was specified, then look for validators.txt
932 // in the same directory as the config file, but don't complain
933 // if we can't find it.
934 boost::filesystem::path validatorsFile;
935
936 if (getSingleSection(secConfig, SECTION_VALIDATORS_FILE, strTemp, j_))
937 {
938 validatorsFile = strTemp;
939
940 if (validatorsFile.empty())
941 {
942 Throw<std::runtime_error>("Invalid path specified in [" SECTION_VALIDATORS_FILE
943 "]");
944 }
945
946 if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty())
947 validatorsFile = CONFIG_DIR / validatorsFile;
948
949 if (!boost::filesystem::exists(validatorsFile))
950 {
951 Throw<std::runtime_error>(
952 "The file specified in [" SECTION_VALIDATORS_FILE
953 "] "
954 "does not exist: " +
955 validatorsFile.string());
956 }
957 else if (
958 !boost::filesystem::is_regular_file(validatorsFile) &&
959 !boost::filesystem::is_symlink(validatorsFile))
960 {
961 Throw<std::runtime_error>(
962 "Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " +
963 validatorsFile.string());
964 }
965 }
966 else if (!CONFIG_DIR.empty())
967 {
968 validatorsFile = CONFIG_DIR / validatorsFileName;
969
970 if (!validatorsFile.empty())
971 {
972 if (!boost::filesystem::exists(validatorsFile))
973 {
974 validatorsFile.clear();
975 }
976 else if (
977 !boost::filesystem::is_regular_file(validatorsFile) &&
978 !boost::filesystem::is_symlink(validatorsFile))
979 {
980 validatorsFile.clear();
981 }
982 }
983 }
984
985 if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
986 (boost::filesystem::is_regular_file(validatorsFile) ||
987 boost::filesystem::is_symlink(validatorsFile)))
988 {
989 boost::system::error_code ec;
990 auto const data = getFileContents(ec, validatorsFile);
991 if (ec)
992 {
993 Throw<std::runtime_error>(
994 "Failed to read '" + validatorsFile.string() + "'." +
995 std::to_string(ec.value()) + ": " + ec.message());
996 }
997
998 auto iniFile = parseIniFile(data, true);
999
1000 auto entries = getIniFileSection(iniFile, SECTION_VALIDATORS);
1001
1002 if (entries != nullptr)
1003 section(SECTION_VALIDATORS).append(*entries);
1004
1005 auto valKeyEntries = getIniFileSection(iniFile, SECTION_VALIDATOR_KEYS);
1006
1007 if (valKeyEntries != nullptr)
1008 section(SECTION_VALIDATOR_KEYS).append(*valKeyEntries);
1009
1010 auto valSiteEntries = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_SITES);
1011
1012 if (valSiteEntries != nullptr)
1013 section(SECTION_VALIDATOR_LIST_SITES).append(*valSiteEntries);
1014
1015 auto valListKeys = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_KEYS);
1016
1017 if (valListKeys != nullptr)
1018 section(SECTION_VALIDATOR_LIST_KEYS).append(*valListKeys);
1019
1020 auto valListThreshold = getIniFileSection(iniFile, SECTION_VALIDATOR_LIST_THRESHOLD);
1021
1022 if (valListThreshold != nullptr)
1023 section(SECTION_VALIDATOR_LIST_THRESHOLD).append(*valListThreshold);
1024
1025 if ((entries == nullptr) && (valKeyEntries == nullptr) && (valListKeys == nullptr))
1026 {
1027 Throw<std::runtime_error>(
1028 "The file specified in [" SECTION_VALIDATORS_FILE
1029 "] "
1030 "does not contain a [" SECTION_VALIDATORS
1031 "], "
1032 "[" SECTION_VALIDATOR_KEYS
1033 "] or "
1034 "[" SECTION_VALIDATOR_LIST_KEYS
1035 "]"
1036 " section: " +
1037 validatorsFile.string());
1038 }
1039 }
1040
1042 auto const& listThreshold = section(SECTION_VALIDATOR_LIST_THRESHOLD);
1043 if (listThreshold.lines().empty())
1044 {
1045 return std::nullopt;
1046 }
1047 if (listThreshold.values().size() == 1)
1048 {
1049 auto strTemp = listThreshold.values()[0];
1050 auto const listThreshold = beast::lexicalCastThrow<std::size_t>(strTemp);
1051 if (listThreshold == 0)
1052 {
1053 return std::nullopt; // NOTE: Explicitly ask for computed
1054 }
1055 if (listThreshold > section(SECTION_VALIDATOR_LIST_KEYS).values().size())
1056 {
1057 Throw<std::runtime_error>(
1058 "Value in config section "
1059 "[" SECTION_VALIDATOR_LIST_THRESHOLD
1060 "] exceeds the number of configured list keys");
1061 }
1062 return listThreshold;
1063 }
1064
1065 Throw<std::runtime_error>(
1066 "Config section "
1067 "[" SECTION_VALIDATOR_LIST_THRESHOLD "] should contain single value only");
1068 }();
1069
1070 // Consolidate [validator_keys] and [validators]
1071 section(SECTION_VALIDATORS).append(section(SECTION_VALIDATOR_KEYS).lines());
1072
1073 if (!section(SECTION_VALIDATOR_LIST_SITES).lines().empty() &&
1074 section(SECTION_VALIDATOR_LIST_KEYS).lines().empty())
1075 {
1076 Throw<std::runtime_error>(
1077 "[" + std::string(SECTION_VALIDATOR_LIST_KEYS) + "] config section is missing");
1078 }
1079 }
1080
1081 {
1082 auto const part = section("features");
1083 for (auto const& s : part.values())
1084 {
1085 if (auto const f = getRegisteredFeature(s))
1086 {
1087 features.insert(*f);
1088 }
1089 else
1090 {
1091 Throw<std::runtime_error>("Unknown feature: " + s + " in config file.");
1092 }
1093 }
1094 }
1095
1096 // This doesn't properly belong here, but check to make sure that the
1097 // value specified for network_quorum is achievable:
1098 {
1099 auto pm = PEERS_MAX;
1100
1101 // FIXME this apparently magic value is actually defined as a constant
1102 // elsewhere (see defaultMaxPeers) but we handle this check here.
1103 if (pm == 0)
1104 pm = 21;
1105
1106 if (NETWORK_QUORUM > pm)
1107 {
1108 Throw<std::runtime_error>(
1109 "The minimum number of required peers (network_quorum) exceeds "
1110 "the maximum number of allowed peers (peers_max)");
1111 }
1112 }
1113}
1114
1115boost::filesystem::path
1117{
1118 auto log_file = DEBUG_LOGFILE;
1119
1120 if (!log_file.empty() && !log_file.is_absolute())
1121 {
1122 // Unless an absolute path for the log file is specified, the
1123 // path is relative to the config file directory.
1124 log_file = boost::filesystem::absolute(log_file, CONFIG_DIR);
1125 }
1126
1127 if (!log_file.empty())
1128 {
1129 auto log_dir = log_file.parent_path();
1130
1131 if (!boost::filesystem::is_directory(log_dir))
1132 {
1133 boost::system::error_code ec;
1134 boost::filesystem::create_directories(log_dir, ec);
1135
1136 // If we fail, we warn but continue so that the calling code can
1137 // decide how to handle this situation.
1138 if (ec)
1139 {
1140 std::cerr << "Unable to create log file path " << log_dir << ": " << ec.message()
1141 << '\n';
1142 }
1143 }
1144 }
1145
1146 return log_file;
1147}
1148
1149int
1151{
1152 auto const index = static_cast<std::underlying_type_t<SizedItem>>(item);
1153 XRPL_ASSERT(index < sizedItems.size(), "xrpl::Config::getValueFor : valid index input");
1154 XRPL_ASSERT(!node || *node <= 4, "xrpl::Config::getValueFor : unset or valid node");
1155 return sizedItems.at(index).second.at(node.value_or(NODE_SIZE));
1156}
1157
1159setup_FeeVote(Section const& section)
1160{
1161 FeeSetup setup;
1162 {
1163 std::uint64_t temp = 0;
1164 if (set(temp, "reference_fee", section) &&
1166 setup.reference_fee = temp;
1167 }
1168 {
1169 std::uint32_t temp = 0;
1170 if (set(temp, "account_reserve", section))
1171 setup.account_reserve = temp;
1172 if (set(temp, "owner_reserve", section))
1173 setup.owner_reserve = temp;
1174 }
1175 return setup;
1176}
1177
1178DatabaseCon::Setup
1180{
1181 DatabaseCon::Setup setup;
1182
1183 setup.startUp = c.START_UP;
1184 setup.standAlone = c.standalone();
1185 setup.dataDir = c.legacy("database_path");
1186 if (!setup.standAlone && setup.dataDir.empty())
1187 {
1188 Throw<std::runtime_error>("database_path must be set.");
1189 }
1190
1191 if (!setup.globalPragma)
1192 {
1193 auto const& sqlite = c.section("sqlite");
1195 result->reserve(3);
1196
1197 // defaults
1198 std::string safety_level;
1199 std::string journal_mode = "wal";
1200 std::string synchronous = "normal";
1201 std::string temp_store = "file";
1202 bool showRiskWarning = false;
1203
1204 if (set(safety_level, "safety_level", sqlite))
1205 {
1206 if (boost::iequals(safety_level, "low"))
1207 {
1208 // low safety defaults
1209 journal_mode = "memory";
1210 synchronous = "off";
1211 temp_store = "memory";
1212 showRiskWarning = true;
1213 }
1214 else if (!boost::iequals(safety_level, "high"))
1215 {
1216 Throw<std::runtime_error>("Invalid safety_level value: " + safety_level);
1217 }
1218 }
1219
1220 {
1221 // #journal_mode Valid values : delete, truncate, persist,
1222 // memory, wal, off
1223 if (set(journal_mode, "journal_mode", sqlite) && !safety_level.empty())
1224 {
1225 Throw<std::runtime_error>(
1226 "Configuration file may not define both "
1227 "\"safety_level\" and \"journal_mode\"");
1228 }
1229 bool const higherRisk =
1230 boost::iequals(journal_mode, "memory") || boost::iequals(journal_mode, "off");
1231 showRiskWarning = showRiskWarning || higherRisk;
1232 if (higherRisk || boost::iequals(journal_mode, "delete") ||
1233 boost::iequals(journal_mode, "truncate") ||
1234 boost::iequals(journal_mode, "persist") || boost::iequals(journal_mode, "wal"))
1235 {
1236 result->emplace_back(
1237 boost::str(boost::format(CommonDBPragmaJournal) % journal_mode));
1238 }
1239 else
1240 {
1241 Throw<std::runtime_error>("Invalid journal_mode value: " + journal_mode);
1242 }
1243 }
1244
1245 {
1246 // #synchronous Valid values : off, normal, full, extra
1247 if (set(synchronous, "synchronous", sqlite) && !safety_level.empty())
1248 {
1249 Throw<std::runtime_error>(
1250 "Configuration file may not define both "
1251 "\"safety_level\" and \"synchronous\"");
1252 }
1253 bool const higherRisk = boost::iequals(synchronous, "off");
1254 showRiskWarning = showRiskWarning || higherRisk;
1255 if (higherRisk || boost::iequals(synchronous, "normal") ||
1256 boost::iequals(synchronous, "full") || boost::iequals(synchronous, "extra"))
1257 {
1258 result->emplace_back(boost::str(boost::format(CommonDBPragmaSync) % synchronous));
1259 }
1260 else
1261 {
1262 Throw<std::runtime_error>("Invalid synchronous value: " + synchronous);
1263 }
1264 }
1265
1266 {
1267 // #temp_store Valid values : default, file, memory
1268 if (set(temp_store, "temp_store", sqlite) && !safety_level.empty())
1269 {
1270 Throw<std::runtime_error>(
1271 "Configuration file may not define both "
1272 "\"safety_level\" and \"temp_store\"");
1273 }
1274 bool const higherRisk = boost::iequals(temp_store, "memory");
1275 showRiskWarning = showRiskWarning || higherRisk;
1276 if (higherRisk || boost::iequals(temp_store, "default") ||
1277 boost::iequals(temp_store, "file"))
1278 {
1279 result->emplace_back(boost::str(boost::format(CommonDBPragmaTemp) % temp_store));
1280 }
1281 else
1282 {
1283 Throw<std::runtime_error>("Invalid temp_store value: " + temp_store);
1284 }
1285 }
1286
1287 if (showRiskWarning && j && c.LEDGER_HISTORY > SQLITE_TUNING_CUTOFF)
1288 {
1289 JLOG(j->warn()) << "reducing the data integrity guarantees from the "
1290 "default [sqlite] behavior is not recommended for "
1291 "nodes storing large amounts of history, because of the "
1292 "difficulty inherent in rebuilding corrupted data.";
1293 }
1294 XRPL_ASSERT(
1295 result->size() == 3, "xrpl::setup_DatabaseCon::globalPragma : result size is 3");
1296 setup.globalPragma = std::move(result);
1297 }
1298 setup.useGlobalPragma = true;
1299
1300 auto setPragma = [](std::string& pragma, std::string const& key, int64_t value) {
1301 pragma = "PRAGMA " + key + "=" + std::to_string(value) + ";";
1302 };
1303
1304 // Lgr Pragma
1305 setPragma(setup.lgrPragma[0], "journal_size_limit", 1582080);
1306
1307 // TX Pragma
1308 int64_t page_size = 4096;
1309 int64_t journal_size_limit = 1582080;
1310 if (c.exists("sqlite"))
1311 {
1312 auto& s = c.section("sqlite");
1313 set(journal_size_limit, "journal_size_limit", s);
1314 set(page_size, "page_size", s);
1315 if (page_size < 512 || page_size > 65536)
1316 Throw<std::runtime_error>("Invalid page_size. Must be between 512 and 65536.");
1317
1318 if ((page_size & (page_size - 1)) != 0)
1319 Throw<std::runtime_error>("Invalid page_size. Must be a power of 2.");
1320 }
1321
1322 setPragma(setup.txPragma[0], "page_size", page_size);
1323 setPragma(setup.txPragma[1], "journal_size_limit", journal_size_limit);
1324 setPragma(setup.txPragma[2], "max_page_count", 4294967294);
1325 setPragma(setup.txPragma[3], "mmap_size", 17179869184);
1326
1327 return setup;
1328}
1329} // 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:146
std::unordered_set< uint256, beast::uhash<> > features
Definition Config.h:261
bool ELB_SUPPORT
Definition Config.h:129
bool COMPRESSION
Definition Config.h:205
static char const *const configLegacyName
Definition Config.h:80
boost::filesystem::path DEBUG_LOGFILE
Definition Config.h:95
void load()
Definition Config.cpp:429
StartUpType START_UP
Definition Config.h:137
std::optional< std::size_t > VALIDATOR_LIST_THRESHOLD
Definition Config.h:284
boost::filesystem::path CONFIG_FILE
Definition Config.h:89
bool TX_REDUCE_RELAY_ENABLE
Definition Config.h:243
static char const *const configFileName
Definition Config.h:79
int MAX_TRANSACTIONS
Definition Config.h:211
std::size_t PEERS_IN_MAX
Definition Config.h:167
int PATH_SEARCH_MAX
Definition Config.h:184
int PATH_SEARCH_OLD
Definition Config.h:181
bool BETA_RPC_API
Definition Config.h:272
std::chrono::seconds MAX_DIVERGED_TIME
Definition Config.h:269
beast::Journal const j_
Definition Config.h:99
std::vector< std::string > IPS
Definition Config.h:132
bool standalone() const
Definition Config.h:316
bool RUN_STANDALONE
Operate in stand-alone mode.
Definition Config.h:112
int PATH_SEARCH_FAST
Definition Config.h:183
std::string SSL_VERIFY_FILE
Definition Config.h:201
std::size_t PEERS_OUT_MAX
Definition Config.h:166
std::string SERVER_DOMAIN
Definition Config.h:263
int RELAY_UNTRUSTED_VALIDATIONS
Definition Config.h:155
bool SILENT
Definition Config.h:102
std::string SSL_VERIFY_DIR
Definition Config.h:202
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
Definition Config.cpp:285
bool USE_TX_TABLES
Definition Config.h:114
static constexpr int MAX_JOB_QUEUE_TX
Definition Config.h:212
int PREFETCH_WORKERS
Definition Config.h:221
std::size_t TX_RELAY_PERCENTAGE
Definition Config.h:256
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition Config.cpp:452
bool SSL_VERIFY
Definition Config.h:200
boost::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
Definition Config.cpp:1116
bool QUIET
Definition Config.h:101
bool TX_REDUCE_RELAY_METRICS
Definition Config.h:250
std::chrono::seconds MAX_UNKNOWN_TIME
Definition Config.h:266
static constexpr int MIN_JOB_QUEUE_TX
Definition Config.h:213
bool PEER_PRIVATE
Definition Config.h:159
static char const *const validatorsFileName
Definition Config.h:82
std::uint32_t LEDGER_HISTORY
Definition Config.h:192
std::size_t NODE_SIZE
Definition Config.h:198
bool FAST_LOAD
Definition Config.h:275
std::size_t PEERS_MAX
Definition Config.h:165
std::uint32_t FETCH_DEPTH
Definition Config.h:193
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
Definition Config.h:122
int PATH_SEARCH
Definition Config.h:182
std::optional< int > SWEEP_INTERVAL
Definition Config.h:228
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
Definition Config.cpp:250
std::size_t NETWORK_QUORUM
Definition Config.h:150
FeeSetup FEES
Definition Config.h:189
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:1150
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition Config.h:233
int IO_WORKERS
Definition Config.h:220
std::vector< std::string > IPS_FIXED
Definition Config.h:135
std::chrono::seconds AMENDMENT_MAJORITY_TIME
Definition Config.h:216
int RELAY_UNTRUSTED_PROPOSALS
Definition Config.h:156
std::size_t VP_REDUCE_RELAY_SQUELCH_MAX_SELECTED_PEERS
Definition Config.h:239
int WORKERS
Definition Config.h:219
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition Config.h:253
boost::filesystem::path CONFIG_DIR
Definition Config.h:92
bool LEDGER_REPLAY
Definition Config.h:208
static char const *const databaseDirName
Definition Config.h:81
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:1159
std::chrono::duration< int, std::ratio_multiply< days::period, std::ratio< 7 > > > weeks
Definition chrono.h:21
SizedItem
Definition Config.h:27
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:1179
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:403
constexpr char const * CommonDBPragmaSync
Definition DBInit.h:13
std::optional< uint256 > getRegisteredFeature(std::string const &name)
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:91
static std::unique_ptr< std::vector< std::string > const > globalPragma
Definition DatabaseCon.h:90
boost::filesystem::path dataDir
Definition DatabaseCon.h:75
std::array< std::string, 1 > lgrPragma
Definition DatabaseCon.h:92
Fee schedule for startup / standalone, and to vote for.
Definition Config.h:49
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition Config.h:51
XRPAmount account_reserve
The account reserve requirement in drops.
Definition Config.h:54
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
Definition Config.h:57
T substr(T... args)
T to_string(T... args)
T value_or(T... args)