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.
pull/95/head
warptangent 9 years ago
parent d0e434f0d8
commit f11def012f
No known key found for this signature in database
GPG Key ID: 0E490BEBFBE4E92D

@ -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);
}
}
}

Loading…
Cancel
Save