diff options
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.cpp')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index c18db7724..5982b9d9a 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -2450,13 +2450,32 @@ void BlockchainLMDB::check_hard_fork_info() throw0(DB_ERROR("Failed to query m_hf_starting_heights")); if (db_stat1.ms_entries != db_stat2.ms_entries) { - mdb_drop(*txn_ptr, m_hf_starting_heights, 1); - mdb_drop(*txn_ptr, m_hf_versions, 1); + // Empty, but don't delete. This allows this function to be called after + // startup, after the subdbs have already been created, and rest of startup + // can proceed. If these don't exist, hard fork's init() will fail. + // + // If these are empty, hard fork's init() will repopulate the hard fork + // data. + mdb_drop(*txn_ptr, m_hf_starting_heights, 0); + mdb_drop(*txn_ptr, m_hf_versions, 0); } 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__); |