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 ripple {
6
8getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue);
9
12 Application& app,
13 Config const& config,
14 JobQueue& jobQueue)
15{
16 bool use_sqlite = false;
17
18 Section const& rdb_section{config.section(SECTION_RELATIONAL_DB)};
19 if (!rdb_section.empty())
20 {
21 if (boost::iequals(get(rdb_section, "backend"), "sqlite"))
22 {
23 use_sqlite = true;
24 }
25 else
26 {
27 Throw<std::runtime_error>(
28 "Invalid rdb_section backend value: " +
29 get(rdb_section, "backend"));
30 }
31 }
32 else
33 {
34 use_sqlite = true;
35 }
36
37 if (use_sqlite)
38 {
39 return getSQLiteDatabase(app, config, jobQueue);
40 }
41
43}
44
45} // namespace ripple
Section & section(std::string const &name)
Returns the section with the given name.
A pool of threads to perform work.
Definition JobQueue.h:39
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:26
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::unique_ptr< RelationalDatabase > getSQLiteDatabase(Application &app, Config const &config, JobQueue &jobQueue)
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.