diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-08-26 23:43:09 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-08-26 23:43:09 +0200 |
commit | ff0afc196e2dbbea2c6296f93314267045948362 (patch) | |
tree | 253489e690565ff9c63d0fe5d09d0541a9ec3714 /src/blockchain_db/blockchain_db.cpp | |
parent | Merge pull request #2353 (diff) | |
parent | Cleanup test impact of moving blockchain_db_types() (diff) | |
download | monero-ff0afc196e2dbbea2c6296f93314267045948362.tar.xz |
Merge pull request #2313
3dd34a49 Cleanup test impact of moving blockchain_db_types() (Howard Chu)
80344740 More DB support cleanup (Howard Chu)
4c7f8ac0 DB cleanup (Howard Chu)
Diffstat (limited to 'src/blockchain_db/blockchain_db.cpp')
-rw-r--r-- | src/blockchain_db/blockchain_db.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp index a6774a25c..01a59e079 100644 --- a/src/blockchain_db/blockchain_db.cpp +++ b/src/blockchain_db/blockchain_db.cpp @@ -33,6 +33,19 @@ #include "profile_tools.h" #include "ringct/rctOps.h" +#include "lmdb/db_lmdb.h" +#ifdef BERKELEY_DB +#include "berkeleydb/db_bdb.h" +#endif + +static const char *db_types[] = { + "lmdb", +#ifdef BERKELEY_DB + "berkeley", +#endif + NULL +}; + #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "blockchain.db" @@ -41,6 +54,41 @@ using epee::string_tools::pod_to_hex; namespace cryptonote { +bool blockchain_valid_db_type(const std::string& db_type) +{ + int i; + for (i=0; db_types[i]; i++) + { + if (db_types[i] == db_type) + return true; + } + return false; +} + +std::string blockchain_db_types(const std::string& sep) +{ + int i; + std::string ret = ""; + for (i=0; db_types[i]; i++) + { + if (i) + ret += sep; + ret += db_types[i]; + } + return ret; +} + +BlockchainDB *new_db(const std::string& db_type) +{ + if (db_type == "lmdb") + return new BlockchainLMDB(); +#if defined(BERKELEY_DB) + if (db_type == "berkeley") + return new BlockchainBDB(); +#endif + return NULL; +} + void BlockchainDB::pop_block() { block blk; |