From 791d8cb038eb0541dce31705a0ebc11903d4b49b Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 4 Oct 2015 19:00:37 +0100 Subject: db_bdb: fix hard fork keys Berkeley DB requires RECNO keys to be 32 bits, and forbids a key value of 0. --- src/blockchain_db/berkeleydb/db_bdb.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index 2a9e9a7f8..bd579ed38 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -1865,7 +1865,7 @@ void BlockchainBDB::set_hard_fork_starting_height(uint8_t version, uint64_t heig LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); - Dbt_copy val_key(version); + Dbt_copy val_key(version + 1); Dbt_copy val(height); if (m_hf_starting_heights->put(DB_DEFAULT_TX, &val_key, &val, 0)) throw1(DB_ERROR("Error adding hard fork starting height to db transaction.")); @@ -1876,7 +1876,7 @@ uint64_t BlockchainBDB::get_hard_fork_starting_height(uint8_t version) const LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); - Dbt_copy key(version); + Dbt_copy key(version + 1); Dbt_copy result; auto get_result = m_hf_starting_heights->get(DB_DEFAULT_TX, &key, &result, 0); @@ -1893,7 +1893,7 @@ void BlockchainBDB::set_hard_fork_version(uint64_t height, uint8_t version) LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); - Dbt_copy val_key(height); + Dbt_copy val_key(height + 1); Dbt_copy val(version); if (m_hf_versions->put(DB_DEFAULT_TX, &val_key, &val, 0)) throw1(DB_ERROR("Error adding hard fork version to db transaction.")); @@ -1904,7 +1904,7 @@ uint8_t BlockchainBDB::get_hard_fork_version(uint64_t height) const LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); - Dbt_copy key(height); + Dbt_copy key(height + 1); Dbt_copy result; auto get_result = m_hf_versions->get(DB_DEFAULT_TX, &key, &result, 0); -- cgit v1.2.3 From 180bcde866cb74fe1e86c16e1357a2e4eae14ee5 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 4 Oct 2015 19:01:33 +0100 Subject: build: default to Berkeley DB for 32 bit and ARM --- CMakeLists.txt | 9 +++++++++ src/daemon/command_line_args.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e21604f..aef7a52e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,8 +216,17 @@ if (DATABASE STREQUAL "lmdb") endif() endif() endif() + + if (BERKELEY_DB AND (ARCH_WIDTH STREQUAL "32" OR ARM6 OR ARM7)) + message(STATUS "Using Berkeley DB as default DB type") + add_definitions("-DDEFAULT_DB_TYPE=\"berkeley\"") + else() + message(STATUS "Using LMDB as default DB type") + add_definitions("-DDEFAULT_DB_TYPE=\"lmdb\"") + endif() elseif (DATABASE STREQUAL "memory") set(BLOCKCHAIN_DB DB_MEMORY) + add_definitions("-DDEFAULT_DB_TYPE=\"memory\"") else() die("Invalid database type: ${DATABASE}") endif() diff --git a/src/daemon/command_line_args.h b/src/daemon/command_line_args.h index ba98a6ea1..8da470c86 100644 --- a/src/daemon/command_line_args.h +++ b/src/daemon/command_line_args.h @@ -73,7 +73,7 @@ namespace daemon_args const command_line::arg_descriptor arg_db_type = { "db-type" , "Specify database type" - , "lmdb" + , DEFAULT_DB_TYPE }; const command_line::arg_descriptor arg_prep_blocks_threads = { "prep-blocks-threads" -- cgit v1.2.3