diff options
author | warptangent <warptangent@tutanota.com> | 2015-12-24 12:22:09 -0800 |
---|---|---|
committer | warptangent <warptangent@tutanota.com> | 2015-12-24 13:30:12 -0800 |
commit | f11def012f38106b0ffeb7010a2f749de1e5b640 (patch) | |
tree | fe4135d297a9819a759b9acda96df5f3e9a14fe3 /src/blockchain_db/lmdb/db_lmdb.cpp | |
parent | Merge pull request #560 (diff) | |
download | monero-f11def012f38106b0ffeb7010a2f749de1e5b640.tar.xz |
BlockchainLMDB: Remove tx outputs in reverse order
Data should be removed in the reverse order it was added.
This matches the order of removal in
blockchain_storage::pop_transaction_from_global_index.
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.cpp')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 4a4550179..84d8cd59e 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -722,15 +722,15 @@ void BlockchainLMDB::remove_tx_outputs(const crypto::hash& tx_hash, const transa size_t num_elems = 0; mdb_cursor_count(cur, &num_elems); - mdb_cursor_get(cur, &k, &v, MDB_FIRST_DUP); + mdb_cursor_get(cur, &k, &v, MDB_LAST_DUP); - for (uint64_t i = 0; i < num_elems; ++i) + for (uint64_t i = num_elems; i > 0; --i) { - const tx_out tx_output = tx.vout[i]; + const tx_out tx_output = tx.vout[i-1]; remove_output(*(const uint64_t*)v.mv_data, tx_output.amount); - if (i < num_elems - 1) + if (i > 1) { - mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); + mdb_cursor_get(cur, &k, &v, MDB_PREV_DUP); } } } |