db_lmdb: guard against going out of sync on unexpected db results

m_num_outputs keeps track of the number of outputs, which should
be the same as the size of both the output_txs and output_amounts
databases. If one goes out of sync, we need to throw to abort
whatever it is we were doing.
This commit is contained in:
moneromooo-monero 2016-12-01 14:29:35 +00:00
parent bef51e677e
commit c96f9b0255
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -910,7 +910,7 @@ void BlockchainLMDB::remove_output(const uint64_t amount, const uint64_t& out_in
result = mdb_cursor_get(m_cur_output_txs, (MDB_val *)&zerokval, &otxk, MDB_GET_BOTH); result = mdb_cursor_get(m_cur_output_txs, (MDB_val *)&zerokval, &otxk, MDB_GET_BOTH);
if (result == MDB_NOTFOUND) if (result == MDB_NOTFOUND)
{ {
LOG_PRINT_L0("Unexpected: global output index not found in m_output_txs"); throw0(DB_ERROR("Unexpected: global output index not found in m_output_txs"));
} }
else if (result) else if (result)
{ {