aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2015-03-13 21:39:27 -0400
committerThomas Winget <tewinget@gmail.com>2015-03-13 21:39:27 -0400
commiteee3ee70730bc3bf7874e5f22139a55dac3a2cdd (patch)
treee36c6344d008e2112d3593ff318ca6733f3b6e50
parentFixed includes in BlockchainDB unit tests (diff)
downloadmonero-eee3ee70730bc3bf7874e5f22139a55dac3a2cdd.tar.xz
BlockchainDB implementations have names now
In order to make things more general, BlockchainDB now has get_db_name() which should return a string with the "name" of that type of db. This "name" will be the subfolder name that holds that db type's files within the monero folder. Small bugfix: blockchain_converter was not correctly appending this in the prior hard-coded-string implementation of the subfolder data directory concept.
-rw-r--r--src/blockchain_converter/blockchain_converter.cpp6
-rw-r--r--src/blockchain_db/blockchain_db.h3
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp7
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
-rw-r--r--src/cryptonote_core/blockchain.cpp5
5 files changed, 20 insertions, 3 deletions
diff --git a/src/blockchain_converter/blockchain_converter.cpp b/src/blockchain_converter/blockchain_converter.cpp
index aae569e58..8ac9b81bb 100644
--- a/src/blockchain_converter/blockchain_converter.cpp
+++ b/src/blockchain_converter/blockchain_converter.cpp
@@ -71,7 +71,11 @@ int main(int argc, char* argv[])
blockchain = new BlockchainLMDB();
- blockchain->open(default_data_path.string());
+ boost::filesystem::path db_path(default_data_path);
+
+ db_path /= blockchain->get_db_name();
+
+ blockchain->open(db_path.string());
for (uint64_t height, i = 0; i < (height = c.m_storage.get_current_blockchain_height()); ++i)
{
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index 2a7fa8f82..d2b4a07a7 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -343,6 +343,9 @@ public:
// get all files used by this db (if any)
virtual std::vector<std::string> get_filenames() const = 0;
+ // return the name of the folder the db's file(s) should reside in
+ virtual std::string get_db_name() const = 0;
+
// FIXME: these are just for functionality mocking, need to implement
// RAII-friendly and multi-read one-write friendly locking mechanism
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index feff4a272..ee49e1827 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -775,6 +775,13 @@ std::vector<std::string> BlockchainLMDB::get_filenames() const
return filenames;
}
+std::string BlockchainLMDB::get_db_name() const
+{
+ LOG_PRINT_L3("BlockchainLMDB::" << __func__);
+
+ return std::string("lmdb");
+}
+
// TODO: this?
bool BlockchainLMDB::lock()
{
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index f6582fce4..1a684548e 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -126,6 +126,8 @@ public:
virtual std::vector<std::string> get_filenames() const;
+ virtual std::string get_db_name() const;
+
virtual bool lock();
virtual void unlock();
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 9f4895736..b7920c99c 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -231,17 +231,18 @@ bool Blockchain::init(const std::string& config_folder, bool testnet)
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
+ // TODO: make this configurable
m_db = new BlockchainLMDB();
m_config_folder = config_folder;
m_testnet = testnet;
boost::filesystem::path folder(m_config_folder);
- folder /= "lmdb";
+
+ folder /= m_db->get_db_name();
LOG_PRINT_L0("Loading blockchain from folder " << folder.c_str() << " ...");
- //FIXME: update filename for BlockchainDB
const std::string filename = folder.string();
try
{