-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocksdbconfig.cpp
36 lines (31 loc) · 1.42 KB
/
rocksdbconfig.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <vxldollar/lib/config.hpp>
#include <vxldollar/lib/rocksdbconfig.hpp>
#include <vxldollar/lib/tomlconfig.hpp>
vxldollar::error vxldollar::rocksdb_config::serialize_toml (vxldollar::tomlconfig & toml) const
{
toml.put ("enable", enable, "Whether to use the RocksDB backend for the ledger database.\ntype:bool");
toml.put ("memory_multiplier", memory_multiplier, "This will modify how much memory is used represented by 1 (low), 2 (medium), 3 (high). Default is 2.\ntype:uint8");
toml.put ("io_threads", io_threads, "Number of threads to use with the background compaction and flushing. Number of hardware threads is recommended.\ntype:uint32");
return toml.get_error ();
}
vxldollar::error vxldollar::rocksdb_config::deserialize_toml (vxldollar::tomlconfig & toml)
{
toml.get_optional<bool> ("enable", enable);
toml.get_optional<uint8_t> ("memory_multiplier", memory_multiplier);
toml.get_optional<unsigned> ("io_threads", io_threads);
// Validate ranges
if (io_threads == 0)
{
toml.get_error ().set ("io_threads must be non-zero");
}
if (memory_multiplier < 1 || memory_multiplier > 3)
{
toml.get_error ().set ("memory_multiplier must be either 1, 2 or 3");
}
return toml.get_error ();
}
bool vxldollar::rocksdb_config::using_rocksdb_in_tests ()
{
auto use_rocksdb_str = std::getenv ("TEST_USE_ROCKSDB");
return use_rocksdb_str && (boost::lexical_cast<int> (use_rocksdb_str) == 1);
}