mirror of
https://github.com/monero-project/monero.git
synced 2025-08-14 03:25:35 -04:00
blockchain: allow marking "tx not found" without an exception
This is a normal occurence in many cases, and there is no need to spam the log with those when it is.
This commit is contained in:
parent
049b7e9a93
commit
0478ac6848
5 changed files with 33 additions and 8 deletions
|
@ -1791,7 +1791,7 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
transaction BlockchainLMDB::get_tx(const crypto::hash& h) const
|
||||
bool BlockchainLMDB::get_tx(const crypto::hash& h, transaction &tx) const
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
check_open();
|
||||
|
@ -1810,19 +1810,27 @@ transaction BlockchainLMDB::get_tx(const crypto::hash& h) const
|
|||
get_result = mdb_cursor_get(m_cur_txs, &val_tx_id, &result, MDB_SET);
|
||||
}
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
throw1(TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str()));
|
||||
return false;
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch tx from hash", get_result).c_str()));
|
||||
|
||||
blobdata bd;
|
||||
bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
|
||||
|
||||
transaction tx;
|
||||
if (!parse_and_validate_tx_from_blob(bd, tx))
|
||||
throw0(DB_ERROR("Failed to parse tx from blob retrieved from the db"));
|
||||
|
||||
TXN_POSTFIX_RDONLY();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
transaction BlockchainLMDB::get_tx(const crypto::hash& h) const
|
||||
{
|
||||
transaction tx;
|
||||
|
||||
if (!get_tx(h, tx))
|
||||
throw1(TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str()));
|
||||
return tx;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue