rippled
Loading...
Searching...
No Matches
RelationalDatabase.cpp
1#include <xrpld/app/main/Application.h>
2#include <xrpld/app/rdb/RelationalDatabase.h>
3#include <xrpld/core/ConfigSections.h>
4
5namespace xrpl {
6
8getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue);
9
11RelationalDatabase::init(Application& app, Config const& config, JobQueue& jobQueue)
12{
13 bool use_sqlite = false;
14
15 Section const& rdb_section{config.section(SECTION_RELATIONAL_DB)};
16 if (!rdb_section.empty())
17 {
18 if (boost::iequals(get(rdb_section, "backend"), "sqlite"))
19 {
20 use_sqlite = true;
21 }
22 else
23 {
24 Throw<std::runtime_error>("Invalid rdb_section backend value: " + get(rdb_section, "backend"));
25 }
26 }
27 else
28 {
29 use_sqlite = true;
30 }
31
32 if (use_sqlite)
33 {
34 return getSQLiteDatabase(app, config, jobQueue);
35 }
36
38}
39
40} // namespace xrpl
Section & section(std::string const &name)
Returns the section with the given name.
A pool of threads to perform work.
Definition JobQueue.h:38
static std::unique_ptr< RelationalDatabase > init(Application &app, Config const &config, JobQueue &jobQueue)
init Creates and returns an appropriate RelationalDatabase instance based on configuration.
Holds a collection of configuration values.
Definition BasicConfig.h:25
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
std::unique_ptr< RelationalDatabase > getSQLiteDatabase(Application &app, Config const &config, JobQueue &jobQueue)