aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_converter
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2015-03-25 11:41:30 -0400
committerThomas Winget <tewinget@gmail.com>2015-03-25 12:09:44 -0400
commit7b14d4a17f739c383322312f1a597f264c074c6e (patch)
tree3934f69a876d5f10637c93fc868d5a8f139aa164 /src/blockchain_converter
parentupdate berkeleydb branch to blockchain branch (diff)
downloadmonero-7b14d4a17f739c383322312f1a597f264c074c6e.tar.xz
Steps toward multiple dbs available -- working
There will need to be some more refactoring for these changes to be considered complete/correct, but for now it's working. new daemon cli argument "--db-type", works for LMDB and BerkeleyDB. A good deal of refactoring is also present in this commit, namely Blockchain no longer instantiates BlockchainDB, but rather is passed a pointer to an already-instantiated BlockchainDB on init().
Diffstat (limited to 'src/blockchain_converter')
-rw-r--r--src/blockchain_converter/fake_core.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/blockchain_converter/fake_core.h b/src/blockchain_converter/fake_core.h
index 175cb4660..f82b05d04 100644
--- a/src/blockchain_converter/fake_core.h
+++ b/src/blockchain_converter/fake_core.h
@@ -29,8 +29,10 @@
#pragma once
#include <boost/filesystem.hpp>
-#include "cryptonote_core/blockchain.h" // BlockchainDB and LMDB
+#include "cryptonote_core/blockchain.h" // BlockchainDB
#include "cryptonote_core/blockchain_storage.h" // in-memory DB
+#include "blockchain_db/blockchain_db.h"
+#include "blockchain_db/lmdb/db_lmdb.h"
using namespace cryptonote;
@@ -53,7 +55,27 @@ struct fake_core_lmdb
#endif
{
m_pool.init(path.string());
- m_storage.init(path.string(), use_testnet, mdb_flags);
+
+ BlockchainDB* db = new BlockchainLMDB();
+
+ boost::filesystem::path folder(path);
+
+ folder /= db->get_db_name();
+
+ LOG_PRINT_L0("Loading blockchain from folder " << folder.c_str() << " ...");
+
+ const std::string filename = folder.string();
+ try
+ {
+ db->open(filename, mdb_flags);
+ }
+ catch (const std::exception& e)
+ {
+ LOG_PRINT_L0("Error opening database: " << e.what());
+ throw;
+ }
+
+ m_storage.init(db, use_testnet);
if (do_batch)
m_storage.get_db().set_batch_transactions(do_batch);
support_batch = true;