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>
116 Throw<std::runtime_error>(
"database_path must be set.");
122 auto const& sqlite = c.
section(
"sqlite");
123 auto result = std::make_unique<std::vector<std::string>>();
131 bool showRiskWarning =
false;
133 if (
set(safety_level,
"safety_level", sqlite))
135 if (boost::iequals(safety_level,
"low"))
138 journal_mode =
"memory";
140 temp_store =
"memory";
141 showRiskWarning =
true;
143 else if (!boost::iequals(safety_level,
"high"))
145 Throw<std::runtime_error>(
146 "Invalid safety_level value: " + safety_level);
153 if (
set(journal_mode,
"journal_mode", sqlite) &&
154 !safety_level.
empty())
156 Throw<std::runtime_error>(
157 "Configuration file may not define both "
158 "\"safety_level\" and \"journal_mode\"");
160 bool higherRisk = boost::iequals(journal_mode,
"memory") ||
161 boost::iequals(journal_mode,
"off");
162 showRiskWarning = showRiskWarning || higherRisk;
163 if (higherRisk || boost::iequals(journal_mode,
"delete") ||
164 boost::iequals(journal_mode,
"truncate") ||
165 boost::iequals(journal_mode,
"persist") ||
166 boost::iequals(journal_mode,
"wal"))
168 result->emplace_back(boost::str(
173 Throw<std::runtime_error>(
174 "Invalid journal_mode value: " + journal_mode);
180 if (
set(synchronous,
"synchronous", sqlite) &&
181 !safety_level.
empty())
183 Throw<std::runtime_error>(
184 "Configuration file may not define both "
185 "\"safety_level\" and \"synchronous\"");
187 bool higherRisk = boost::iequals(synchronous,
"off");
188 showRiskWarning = showRiskWarning || higherRisk;
189 if (higherRisk || boost::iequals(synchronous,
"normal") ||
190 boost::iequals(synchronous,
"full") ||
191 boost::iequals(synchronous,
"extra"))
193 result->emplace_back(boost::str(
198 Throw<std::runtime_error>(
199 "Invalid synchronous value: " + synchronous);
205 if (
set(temp_store,
"temp_store", sqlite) &&
206 !safety_level.
empty())
208 Throw<std::runtime_error>(
209 "Configuration file may not define both "
210 "\"safety_level\" and \"temp_store\"");
212 bool higherRisk = boost::iequals(temp_store,
"memory");
213 showRiskWarning = showRiskWarning || higherRisk;
214 if (higherRisk || boost::iequals(temp_store,
"default") ||
215 boost::iequals(temp_store,
"file"))
217 result->emplace_back(boost::str(
222 Throw<std::runtime_error>(
223 "Invalid temp_store value: " + temp_store);
230 <<
"reducing the data integrity guarantees from the "
231 "default [sqlite] behavior is not recommended for "
232 "nodes storing large amounts of history, because of the "
233 "difficulty inherent in rebuilding corrupted data.";
235 assert(result->size() == 3);
251 Throw<std::logic_error>(
"No JobQueue");