1
0
Fork 0
forked from lthn/blockchain

added cmake paramter to have mdbx as an option

This commit is contained in:
cryptozoidberg 2019-08-31 14:41:18 +02:00
parent b69a9b9bf4
commit 84dfc6917a
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
11 changed files with 54 additions and 21 deletions

View file

@ -215,7 +215,13 @@ else()
endif()
set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests")
set(DB_ENGINE "lmdb" CACHE STRING "Select database engine")
if (DB_ENGINE STREQUAL "lmdb")
add_definitions(-DDB_ENGINE_LMDB)
elseif(DB_ENGINE STREQUAL "mdbx")
add_definitions(-DDB_ENGINE_MDBX)
endif()
add_subdirectory(contrib)
add_subdirectory(src)

View file

@ -9,9 +9,7 @@ add_subdirectory(ethereum)
set_property(TARGET upnpc-static PROPERTY FOLDER "contrib/miniupnp")
set_property(TARGET zlibstatic PROPERTY FOLDER "contrib")
set_property(TARGET lmdb PROPERTY FOLDER "contrib")
set_property(TARGET mdbx PROPERTY FOLDER "contrib")
set_property(TARGET ${DB_ENGINE} PROPERTY FOLDER "contrib")

View file

@ -1,8 +1,15 @@
add_subdirectory(liblmdb)
add_subdirectory(libmdbx)
if(MSVC)
target_compile_options(lmdb PRIVATE /wd4996 /wd4503 /wd4345 /wd4267 /wd4244 /wd4146 /wd4333 /wd4172)
else()
# Warnings as used by LMDB itself (LMDB_0.9.23)
target_compile_options(lmdb PRIVATE -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized)
if (DB_ENGINE STREQUAL "lmdb")
message("DB ENGINE: lmdb")
add_subdirectory(liblmdb)
if(MSVC)
target_compile_options(lmdb PRIVATE /wd4996 /wd4503 /wd4345 /wd4267 /wd4244 /wd4146 /wd4333 /wd4172)
else()
# Warnings as used by LMDB itself (LMDB_0.9.23)
target_compile_options(lmdb PRIVATE -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized)
endif()
elseif(DB_ENGINE STREQUAL "mdbx")
message("DB ENGINE: mdbx")
add_subdirectory(libmdbx)
endif()

View file

@ -116,7 +116,7 @@ add_library(wallet ${WALLET})
add_dependencies(wallet version ${PCH_LIB_NAME})
ENABLE_SHARED_PCH(WALLET)
target_link_libraries(currency_core mdbx lmdb)
target_link_libraries(currency_core ${DB_ENGINE})
add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL})
add_dependencies(daemon version)

View file

@ -3,6 +3,8 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef DB_ENGINE_LMDB
#include "db_backend_lmdb.h"
#include "misc_language.h"
#include "string_coding.h"
@ -388,3 +390,4 @@ namespace tools
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL NULL
#endif

View file

@ -4,6 +4,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#ifdef DB_ENGINE_LMDB
#include <thread>
#include "include_base_utils.h"
@ -60,3 +62,4 @@ namespace tools
};
}
}
#endif

View file

@ -3,12 +3,15 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifdef DB_ENGINE_MDBX
#include "db_backend_mdbx.h"
#include "misc_language.h"
#include "string_coding.h"
#include "profile_tools.h"
#include "util.h"
#define BUF_SIZE 1024
#define CHECK_AND_ASSERT_MESS_MDBX_DB(rc, ret, mess) CHECK_AND_ASSERT_MES(res == MDBX_SUCCESS, ret, "[DB ERROR]:(" << rc << ")" << mdbx_strerror(rc) << ", [message]: " << mess);
@ -394,3 +397,5 @@ namespace tools
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL NULL
#endif

View file

@ -4,6 +4,9 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#ifdef DB_ENGINE_MDBX
#include <thread>
#include "include_base_utils.h"
@ -58,5 +61,8 @@ namespace tools
MDBX_txn* get_current_tx();
};
}
}
#endif

View file

@ -14,8 +14,7 @@
#include "include_base_utils.h"
#include "common/db_backend_lmdb.h"
#include "common/db_backend_mdbx.h"
#include "common/db_backend_selector.h"
#include "common/command_line.h"
#include "blockchain_storage.h"
@ -81,7 +80,7 @@ namespace
}
//------------------------------------------------------------------
blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(std::shared_ptr<tools::db::i_db_backend>(new tools::db::mdbx_db_backend), m_rw_lock),
blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(std::shared_ptr<tools::db::i_db_backend>(new tools::db::default_db_backend), m_rw_lock),
m_db_blocks(m_db),
m_db_blocks_index(m_db),
m_db_transactions(m_db),

View file

@ -189,10 +189,16 @@
#define CURRENCY_POOLDATA_FOLDERNAME_OLD "poolstate"
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD "blockchain"
//#define CURRENCY_POOLDATA_FOLDERNAME "poolstate_lmdb_v1"
//#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME "blockchain_lmdb_v1"
#define CURRENCY_POOLDATA_FOLDERNAME "poolstate_mdbx_v1"
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME "blockchain_mdbx_v1"
#ifdef DB_ENGINE_LMDB
#define CURRENCY_BLOCKCHAINDATA_DB_ENGINE_NAME "lmdb"
#elif DB_ENGINE_MDBX
#define CURRENCY_BLOCKCHAINDATA_DB_ENGINE_NAME "mdbx"
#endif
#define CURRENCY_POOLDATA_FOLDERNAME "poolstate_" CURRENCY_BLOCKCHAINDATA_DB_ENGINE_NAME "_v1"
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME "blockchain_" CURRENCY_BLOCKCHAINDATA_DB_ENGINE_NAME "_v1"
#define P2P_NET_DATA_FILENAME "p2pstate.bin"
#define MINER_CONFIG_FILENAME "miner_conf.json"
#define GUI_SECURE_CONFIG_FILENAME "gui_secure_conf.bin"

View file

@ -9,7 +9,7 @@
#include <unordered_set>
#include <vector>
#include "common/db_backend_lmdb.h"
#include "common/db_backend_selector.h"
#include "tx_pool.h"
#include "currency_boost_serialization.h"
#include "currency_core/currency_config.h"
@ -42,7 +42,7 @@ namespace currency
tx_memory_pool::tx_memory_pool(blockchain_storage& bchs, i_currency_protocol* pprotocol) :
m_blockchain(bchs),
m_pprotocol(pprotocol),
m_db(std::shared_ptr<tools::db::i_db_backend>(new tools::db::lmdb_db_backend), m_dummy_rw_lock),
m_db(std::shared_ptr<tools::db::i_db_backend>(new tools::db::default_db_backend), m_dummy_rw_lock),
m_db_transactions(m_db),
m_db_black_tx_list(m_db),
m_db_solo_options(m_db),