aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 2281c1da0..ea33dc6c9 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -880,12 +880,11 @@ void BlockchainLMDB::remove_tx_outputs(const uint64_t tx_id, const transaction&
throw0(DB_ERROR("tx has outputs, but no output indices found"));
}
- bool is_miner_tx = tx.vin.size() == 1 && tx.vin[0].type() == typeid(txin_gen);
- for (uint64_t i = tx.vout.size(); i > 0; --i)
+ bool is_pseudo_rct = tx.version >= 2 && tx.vin.size() == 1 && tx.vin[0].type() == typeid(txin_gen);
+ for (size_t i = tx.vout.size(); i-- > 0;)
{
- const tx_out tx_output = tx.vout[i-1];
- uint64_t amount = is_miner_tx && tx.version >= 2 ? 0 : tx_output.amount;
- remove_output(amount, amount_output_indices[i-1]);
+ uint64_t amount = is_pseudo_rct ? 0 : tx.vout[i].amount;
+ remove_output(amount, amount_output_indices[i]);
}
}
@@ -906,7 +905,7 @@ void BlockchainLMDB::remove_output(const uint64_t amount, const uint64_t& out_in
else if (result)
throw0(DB_ERROR(lmdb_error("DB error attempting to get an output", result).c_str()));
- outkey *ok = (outkey *)v.mv_data;
+ const pre_rct_outkey *ok = (const pre_rct_outkey *)v.mv_data;
MDB_val_set(otxk, ok->output_id);
result = mdb_cursor_get(m_cur_output_txs, (MDB_val *)&zerokval, &otxk, MDB_GET_BOTH);
if (result == MDB_NOTFOUND)
@@ -2044,9 +2043,10 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_amount_output_indices(const uint64_
else if (result)
throw0(DB_ERROR(lmdb_error("DB error attempting to get data for tx_outputs[tx_index]", result).c_str()));
- uint64_t* indices = (uint64_t*)v.mv_data;
+ const uint64_t* indices = (const uint64_t*)v.mv_data;
int num_outputs = v.mv_size / sizeof(uint64_t);
+ amount_output_indices.reserve(num_outputs);
for (int i = 0; i < num_outputs; ++i)
{
// LOG_PRINT_L0("amount output index[" << 2*i << "]" << ": " << paired_indices[2*i] << " global output index: " << paired_indices[2*i+1]);
@@ -2647,7 +2647,7 @@ void BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, const std::
else if (get_result)
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve an output from the db", get_result).c_str()));
- outkey *okp = (outkey *)v.mv_data;
+ const outkey *okp = (const outkey *)v.mv_data;
tx_indices.push_back(okp->output_id);
}