From c657e772c4efbfee8ff698883f1532a38117a70a Mon Sep 17 00:00:00 2001 From: warptangent Date: Thu, 4 Feb 2016 17:15:37 -0800 Subject: blockchain_import: Add --drop-hard-fork command --- src/blockchain_db/berkeleydb/db_bdb.cpp | 5 +++++ src/blockchain_db/berkeleydb/db_bdb.h | 1 + src/blockchain_db/blockchain_db.h | 1 + src/blockchain_db/lmdb/db_lmdb.cpp | 13 +++++++++++++ src/blockchain_db/lmdb/db_lmdb.h | 1 + 5 files changed, 21 insertions(+) (limited to 'src/blockchain_db') diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index 6c80d1333..2c18ae5df 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -2192,6 +2192,11 @@ void BlockchainBDB::check_hard_fork_info() /* FIXME: Some other time */ } +void BlockchainBDB::drop_hard_fork_info() +{ + /* TODO */ +} + void BlockchainBDB::set_hard_fork_version(uint64_t height, uint8_t version) { LOG_PRINT_L3("BlockchainBDB::" << __func__); diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index 8cac94f6f..6db91aa1e 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -376,6 +376,7 @@ private: virtual void set_hard_fork_version(uint64_t height, uint8_t version); virtual uint8_t get_hard_fork_version(uint64_t height) const; virtual void check_hard_fork_info(); + virtual void drop_hard_fork_info(); /** * @brief convert a tx output to a blob for storage diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 1f4ee21c2..4a140e5f6 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -503,6 +503,7 @@ public: virtual void set_hard_fork_version(uint64_t height, uint8_t version) = 0; virtual uint8_t get_hard_fork_version(uint64_t height) const = 0; virtual void check_hard_fork_info() = 0; + virtual void drop_hard_fork_info() = 0; virtual bool is_read_only() const = 0; diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index c18db7724..541e838f7 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -2457,6 +2457,19 @@ void BlockchainLMDB::check_hard_fork_info() TXN_POSTFIX_SUCCESS(); } +void BlockchainLMDB::drop_hard_fork_info() +{ + LOG_PRINT_L3("BlockchainLMDB::" << __func__); + check_open(); + + TXN_PREFIX(0); + + mdb_drop(*txn_ptr, m_hf_starting_heights, 1); + mdb_drop(*txn_ptr, m_hf_versions, 1); + + TXN_POSTFIX_SUCCESS(); +} + void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t height) { LOG_PRINT_L3("BlockchainLMDB::" << __func__); diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 48f4adb41..eb0704ab2 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -236,6 +236,7 @@ private: virtual void set_hard_fork_version(uint64_t height, uint8_t version); virtual uint8_t get_hard_fork_version(uint64_t height) const; virtual void check_hard_fork_info(); + virtual void drop_hard_fork_info(); /** * @brief convert a tx output to a blob for storage -- cgit v1.2.3