20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/contract.h>
22 #include <ripple/core/DatabaseCon.h>
23 #include <ripple/core/SociDB.h>
25 #include <boost/algorithm/string.hpp>
26 #include <boost/format.hpp>
102 Throw<std::runtime_error>(
"database_path must be set.");
108 auto const& sqlite = c.
section(
"sqlite");
109 auto result = std::make_unique<std::vector<std::string>>();
117 bool showRiskWarning =
false;
119 if (
set(safety_level,
"safety_level", sqlite))
121 if (boost::iequals(safety_level,
"low"))
124 journal_mode =
"memory";
126 temp_store =
"memory";
127 showRiskWarning =
true;
129 else if (!boost::iequals(safety_level,
"high"))
131 Throw<std::runtime_error>(
132 "Invalid safety_level value: " + safety_level);
139 if (
set(journal_mode,
"journal_mode", sqlite) &&
140 !safety_level.
empty())
142 Throw<std::runtime_error>(
143 "Configuration file may not define both "
144 "\"safety_level\" and \"journal_mode\"");
146 bool higherRisk = boost::iequals(journal_mode,
"memory") ||
147 boost::iequals(journal_mode,
"off");
148 showRiskWarning = showRiskWarning || higherRisk;
149 if (higherRisk || boost::iequals(journal_mode,
"delete") ||
150 boost::iequals(journal_mode,
"truncate") ||
151 boost::iequals(journal_mode,
"persist") ||
152 boost::iequals(journal_mode,
"wal"))
154 result->emplace_back(boost::str(
159 Throw<std::runtime_error>(
160 "Invalid journal_mode value: " + journal_mode);
166 if (
set(synchronous,
"synchronous", sqlite) &&
167 !safety_level.
empty())
169 Throw<std::runtime_error>(
170 "Configuration file may not define both "
171 "\"safety_level\" and \"synchronous\"");
173 bool higherRisk = boost::iequals(synchronous,
"off");
174 showRiskWarning = showRiskWarning || higherRisk;
175 if (higherRisk || boost::iequals(synchronous,
"normal") ||
176 boost::iequals(synchronous,
"full") ||
177 boost::iequals(synchronous,
"extra"))
179 result->emplace_back(boost::str(
184 Throw<std::runtime_error>(
185 "Invalid synchronous value: " + synchronous);
191 if (
set(temp_store,
"temp_store", sqlite) &&
192 !safety_level.
empty())
194 Throw<std::runtime_error>(
195 "Configuration file may not define both "
196 "\"safety_level\" and \"temp_store\"");
198 bool higherRisk = boost::iequals(temp_store,
"memory");
199 showRiskWarning = showRiskWarning || higherRisk;
200 if (higherRisk || boost::iequals(temp_store,
"default") ||
201 boost::iequals(temp_store,
"file"))
203 result->emplace_back(boost::str(
208 Throw<std::runtime_error>(
209 "Invalid temp_store value: " + temp_store);
216 <<
"reducing the data integrity guarantees from the "
217 "default [sqlite] behavior is not recommended for "
218 "nodes storing large amounts of history, because of the "
219 "difficulty inherent in rebuilding corrupted data.";
221 assert(result->size() == 3);
237 Throw<std::logic_error>(
"No JobQueue");