fake_core: Check if hard fork subdbs need reset at start

This commit is contained in:
warptangent 2016-02-04 20:09:51 -08:00
parent c657e772c4
commit f7e337e625
No known key found for this signature in database
GPG Key ID: 0E490BEBFBE4E92D
2 changed files with 11 additions and 2 deletions

View File

@ -2450,8 +2450,14 @@ 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();

View File

@ -75,7 +75,10 @@ struct fake_core_lmdb
throw;
}
db->check_hard_fork_info();
m_storage.init(db, use_testnet);
if (do_batch)
m_storage.get_db().set_batch_transactions(do_batch);
support_batch = true;