DB cleanup
Hide LMDB-specific stuff behind blockchain_db.h. Nobody besides blockchain_db.cpp should ever be including DB-specific headers any more.
This commit is contained in:
@@ -1083,9 +1083,10 @@ BlockchainLMDB::BlockchainLMDB(bool batch_transactions)
|
||||
m_hardfork = nullptr;
|
||||
}
|
||||
|
||||
void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
|
||||
void BlockchainLMDB::open(const std::string& filename, const int db_flags)
|
||||
{
|
||||
int result;
|
||||
int mdb_flags = MDB_NORDAHEAD;
|
||||
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
|
||||
@@ -1124,6 +1125,15 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
|
||||
|
||||
size_t mapsize = DEFAULT_MAPSIZE;
|
||||
|
||||
if (db_flags & DBF_FAST)
|
||||
mdb_flags |= MDB_NOSYNC;
|
||||
if (db_flags & DBF_FASTEST)
|
||||
mdb_flags |= MDB_NOSYNC | MDB_WRITEMAP | MDB_MAPASYNC;
|
||||
if (db_flags & DBF_RDONLY)
|
||||
mdb_flags = MDB_RDONLY;
|
||||
if (db_flags & DBF_SALVAGE)
|
||||
mdb_flags |= MDB_PREVSNAPSHOT;
|
||||
|
||||
if (auto result = mdb_env_open(m_env, filename.c_str(), mdb_flags, 0644))
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open lmdb environment: ", result).c_str()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user