20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/contract.h>
22 #include <ripple/core/DatabaseCon.h>
23 #include <ripple/core/SociDB.h>
24 #include <boost/algorithm/string.hpp>
25 #include <boost/format.hpp>
40 Throw<std::runtime_error>(
"database_path must be set.");
46 auto const& sqlite = c.
section(
"sqlite");
47 auto result = std::make_unique<std::vector<std::string>>();
55 bool showRiskWarning =
false;
57 if (
set(safety_level,
"safety_level", sqlite))
59 if (boost::iequals(safety_level,
"low"))
62 journal_mode =
"memory";
64 temp_store =
"memory";
65 showRiskWarning =
true;
67 else if (!boost::iequals(safety_level,
"high"))
69 Throw<std::runtime_error>(
70 "Invalid safety_level value: " + safety_level);
77 if (
set(journal_mode,
"journal_mode", sqlite) &&
78 !safety_level.
empty())
80 Throw<std::runtime_error>(
81 "Configuration file may not define both "
82 "\"safety_level\" and \"journal_mode\"");
84 bool higherRisk = boost::iequals(journal_mode,
"memory") ||
85 boost::iequals(journal_mode,
"off");
86 showRiskWarning = showRiskWarning || higherRisk;
87 if (higherRisk || boost::iequals(journal_mode,
"delete") ||
88 boost::iequals(journal_mode,
"truncate") ||
89 boost::iequals(journal_mode,
"persist") ||
90 boost::iequals(journal_mode,
"wal"))
92 result->emplace_back(boost::str(
97 Throw<std::runtime_error>(
98 "Invalid journal_mode value: " + journal_mode);
104 if (
set(synchronous,
"synchronous", sqlite) &&
105 !safety_level.
empty())
107 Throw<std::runtime_error>(
108 "Configuration file may not define both "
109 "\"safety_level\" and \"synchronous\"");
111 bool higherRisk = boost::iequals(synchronous,
"off");
112 showRiskWarning = showRiskWarning || higherRisk;
113 if (higherRisk || boost::iequals(synchronous,
"normal") ||
114 boost::iequals(synchronous,
"full") ||
115 boost::iequals(synchronous,
"extra"))
117 result->emplace_back(boost::str(
122 Throw<std::runtime_error>(
123 "Invalid synchronous value: " + synchronous);
129 if (
set(temp_store,
"temp_store", sqlite) &&
130 !safety_level.
empty())
132 Throw<std::runtime_error>(
133 "Configuration file may not define both "
134 "\"safety_level\" and \"temp_store\"");
136 bool higherRisk = boost::iequals(temp_store,
"memory");
137 showRiskWarning = showRiskWarning || higherRisk;
138 if (higherRisk || boost::iequals(temp_store,
"default") ||
139 boost::iequals(temp_store,
"file"))
141 result->emplace_back(boost::str(
146 Throw<std::runtime_error>(
147 "Invalid temp_store value: " + temp_store);
154 <<
"reducing the data integrity guarantees from the "
155 "default [sqlite] behavior is not recommended for "
156 "nodes storing large amounts of history, because of the "
157 "difficulty inherent in rebuilding corrupted data.";
159 assert(result->size() == 3);
175 Throw<std::logic_error>(
"No JobQueue");