diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-13 11:12:34 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-13 11:14:06 +0000 |
commit | 8af913a3d183b9f30106caaedba007c055ad945e (patch) | |
tree | 3de7e01f502071e6cfa4881c3d0c7ad07cfe84fd /src/blockchain_db/lmdb/db_lmdb.cpp | |
parent | db_bdb: implement BlockchainBDB::reset (diff) | |
download | monero-8af913a3d183b9f30106caaedba007c055ad945e.tar.xz |
db_lmdb: implement BlockchainLMDB::reset
It is needed by the core tests
Diffstat (limited to '')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 2bddcc6f5..62f1b39f1 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -1159,7 +1159,33 @@ void BlockchainLMDB::sync() void BlockchainLMDB::reset() { LOG_PRINT_L3("BlockchainLMDB::" << __func__); - // TODO: this + check_open(); + + mdb_txn_safe txn; + if (mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR("Failed to create a transaction for the db")); + mdb_drop(txn, m_blocks, 0); + mdb_drop(txn, m_block_timestamps, 0); + mdb_drop(txn, m_block_heights, 0); + mdb_drop(txn, m_block_hashes, 0); + mdb_drop(txn, m_block_sizes, 0); + mdb_drop(txn, m_block_diffs, 0); + mdb_drop(txn, m_block_coins, 0); + mdb_drop(txn, m_txs, 0); + mdb_drop(txn, m_tx_unlocks, 0); + mdb_drop(txn, m_tx_heights, 0); + mdb_drop(txn, m_tx_outputs, 0); + mdb_drop(txn, m_output_txs, 0); + mdb_drop(txn, m_output_indices, 0); + mdb_drop(txn, m_output_amounts, 0); + mdb_drop(txn, m_output_keys, 0); + mdb_drop(txn, m_spent_keys, 0); + mdb_drop(txn, m_hf_starting_heights, 0); + mdb_drop(txn, m_hf_versions, 0); + mdb_drop(txn, m_properties, 0); + txn.commit(); + m_height = 0; + m_num_outputs = 0; } std::vector<std::string> BlockchainLMDB::get_filenames() const |