aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/blockchain_db.cpp32
-rw-r--r--src/blockchain_db/db_types.h7
2 files changed, 34 insertions, 5 deletions
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index c7ca533ef..01a59e079 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -38,6 +38,14 @@
#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"
@@ -46,6 +54,30 @@ 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")
diff --git a/src/blockchain_db/db_types.h b/src/blockchain_db/db_types.h
index 6c21b029e..8e2f58a61 100644
--- a/src/blockchain_db/db_types.h
+++ b/src/blockchain_db/db_types.h
@@ -31,9 +31,6 @@
namespace cryptonote
{
-
- const std::unordered_set<std::string> blockchain_db_types =
- { "lmdb"
- };
-
+ bool blockchain_valid_db_type(const std::string& db_type);
+ std::string blockchain_db_types(const std::string& sep);
} // namespace cryptonote