aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorwarptangent <warptangent@tutanota.com>2016-02-17 05:56:32 -0800
committerwarptangent <warptangent@tutanota.com>2016-02-18 06:37:45 -0800
commit47f6cf8beaffa441f3af9ad97b3dfde243d75338 (patch)
treed89052a0b2ca088c28771605c1b33208d7497fc7 /src/blockchain_db
parentMerge pull request #675 (diff)
downloadmonero-47f6cf8beaffa441f3af9ad97b3dfde243d75338.tar.xz
BlockchainBDB: Support blockchain_import --drop-hard-fork command
See c657e772c4efbfee8ff698883f1532a38117a70a for LMDB equivalent.
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index f035bf4c4..93ad6c587 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -1073,8 +1073,10 @@ void BlockchainBDB::sync()
m_spent_keys->sync(0);
- m_hf_starting_heights->sync(0);
- m_hf_versions->sync(0);
+ if (m_hf_starting_heights != nullptr)
+ m_hf_starting_heights->sync(0);
+ if (m_hf_versions != nullptr)
+ m_hf_versions->sync(0);
m_properties->sync(0);
}
@@ -2213,7 +2215,37 @@ void BlockchainBDB::check_hard_fork_info()
void BlockchainBDB::drop_hard_fork_info()
{
- /* TODO */
+ LOG_PRINT_L3("BlockchainBDB::" << __func__);
+ check_open();
+
+ bdb_txn_safe txn;
+ bdb_txn_safe* txn_ptr = &txn;
+ if (m_write_txn)
+ txn_ptr = m_write_txn;
+ else
+ {
+ if (m_env->txn_begin(NULL, txn, 0))
+ throw0(DB_ERROR("Failed to create a transaction for the db"));
+ }
+
+ try
+ {
+ m_hf_starting_heights->close(0);
+ m_hf_versions->close(0);
+ m_hf_starting_heights = nullptr;
+ m_hf_versions = nullptr;
+ if (m_env->dbremove(*txn_ptr, BDB_HF_STARTING_HEIGHTS, NULL, 0) != 0)
+ LOG_ERROR("Error removing hf_starting_heights");
+ if (m_env->dbremove(*txn_ptr, BDB_HF_VERSIONS, NULL, 0) != 0)
+ LOG_ERROR("Error removing hf_versions");
+
+ if (!m_write_txn)
+ txn.commit();
+ }
+ catch (const std::exception& e)
+ {
+ throw0(DB_ERROR(std::string("Failed to drop hard fork info: ").append(e.what()).c_str()));
+ }
}
void BlockchainBDB::set_hard_fork_version(uint64_t height, uint8_t version)