mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge bitcoin/bitcoin#22383: rpc: Prefer to use txindex if available for GetTransaction
78f4c8b98eprefer to use txindex if available for GetTransaction (Jameson Lopp) Pull request description: Fixes #22382 Motivation: prevent excessive disk reads if txindex is enabled. Worth noting that this could be argued to be less of a bug and more of an issue of undefined behavior. If a user calls GetTransaction with the wrong block hash, what should happen? ACKs for top commit: jonatack: ACK78f4c8b98etheStack: Code review ACK78f4c8b98eLarryRuane: tACK78f4c8b98eluke-jr: utACK78f4c8b98ejnewbery: utACK78f4c8b98erajarshimaitra: Code review ACK78f4c8b98elsilva01: Code Review ACK and Tested ACK78f4c8b98eon Ubuntu 20.04 Tree-SHA512: af7db5b98cb2ae4897b28476b2fa243bf7e6f850750d9347062fe8013c5720986d1a3c808f80098e5289bd84b085de03c81a44e584dc28982f721c223651bfe0
This commit is contained in:
@@ -141,15 +141,16 @@ void StartScriptCheckWorkerThreads(int threads_num);
|
||||
/** Stop all of the script checking worker threads */
|
||||
void StopScriptCheckWorkerThreads();
|
||||
/**
|
||||
* Return transaction from the block at block_index.
|
||||
* If block_index is not provided, fall back to mempool.
|
||||
* If mempool is not provided or the tx couldn't be found in mempool, fall back to g_txindex.
|
||||
* Return transaction with a given hash.
|
||||
* If mempool is provided and block_index is not provided, check it first for the tx.
|
||||
* If -txindex is available, check it next for the tx.
|
||||
* Finally, if block_index is provided, check for tx by reading entire block from disk.
|
||||
*
|
||||
* @param[in] block_index The block to read from disk, or nullptr
|
||||
* @param[in] mempool If block_index is not provided, look in the mempool, if provided
|
||||
* @param[in] mempool If provided, check mempool for tx
|
||||
* @param[in] hash The txid
|
||||
* @param[in] consensusParams The params
|
||||
* @param[out] hashBlock The hash of block_index, if the tx was found via block_index
|
||||
* @param[out] hashBlock The block hash, if the tx was found via -txindex or block_index
|
||||
* @returns The tx if found, otherwise nullptr
|
||||
*/
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock);
|
||||
|
||||
Reference in New Issue
Block a user