mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 04:19:24 -05:00
blockchain_db: do not throw on expected partial results getting keys
When scanning for outputs used in a set of incoming blocks, we expect that some of the inputs in their transactions will not be found in the blockchain, as they could be in previous blocks in that set. Those outputs will be scanned there at a later point. In this case, we add a flag to control wehther an output not being found is expected or not.
This commit is contained in:
parent
6e78915061
commit
cca95c1c7a
@ -1184,7 +1184,7 @@ public:
|
||||
* @param offsets a list of amount-specific output indices
|
||||
* @param outputs return-by-reference a list of outputs' metadata
|
||||
*/
|
||||
virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs) = 0;
|
||||
virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs, bool allow_partial = false) = 0;
|
||||
|
||||
/*
|
||||
* FIXME: Need to check with git blame and ask what this does to
|
||||
|
@ -2617,7 +2617,7 @@ void BlockchainLMDB::get_output_tx_and_index_from_global(const std::vector<uint6
|
||||
TXN_POSTFIX_RDONLY();
|
||||
}
|
||||
|
||||
void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs)
|
||||
void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs, bool allow_partial)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
TIME_MEASURE_START(db3);
|
||||
@ -2635,7 +2635,14 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui
|
||||
|
||||
auto get_result = mdb_cursor_get(m_cur_output_amounts, &k, &v, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
if (allow_partial)
|
||||
{
|
||||
MDEBUG("Partial result: " << outputs.size() << "/" << offsets.size());
|
||||
break;
|
||||
}
|
||||
throw1(OUTPUT_DNE((std::string("Attempting to get output pubkey by global index (amount ") + boost::lexical_cast<std::string>(amount) + ", index " + boost::lexical_cast<std::string>(index) + ", count " + boost::lexical_cast<std::string>(get_num_outputs(amount)) + "), but key does not exist").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve an output pubkey from the db", get_result).c_str()));
|
||||
|
||||
|
@ -221,7 +221,7 @@ public:
|
||||
|
||||
virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index);
|
||||
virtual output_data_t get_output_key(const uint64_t& global_index) const;
|
||||
virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs);
|
||||
virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs, bool allow_partial = false);
|
||||
|
||||
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const;
|
||||
virtual void get_output_tx_and_index_from_global(const std::vector<uint64_t> &global_indices,
|
||||
|
@ -3540,7 +3540,7 @@ void Blockchain::output_scan_worker(const uint64_t amount, const std::vector<uin
|
||||
{
|
||||
try
|
||||
{
|
||||
m_db->get_output_key(amount, offsets, outputs);
|
||||
m_db->get_output_key(amount, offsets, outputs, true);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user