diff options
author | fanquake <fanquake@gmail.com> | 2021-08-03 20:06:11 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-08-03 20:07:26 +0800 |
commit | eaf09bda4ab21f79f89822d2c6fa3d7a3ce57b0d (patch) | |
tree | c192f3e8f854fbaaee6f756b60e137d5153fdc70 /src | |
parent | 31a481be297bd76e6e78c6d03e8e7ff2d6fbcd38 (diff) | |
parent | 4a1b2a7ba7f804e656a8cd29d5aa80fcbd40904f (diff) |
Merge bitcoin/bitcoin#22609: [GetTransaction] remove unneeded cs_main lock acquire
4a1b2a7ba7f804e656a8cd29d5aa80fcbd40904f [GetTransaction] remove unneeded `cs_main` lock acquire (Sebastian Falbesoner)
Pull request description:
This PR is a follow-up to #22383. For reading from the mempool, only `mempool.cs` needs to be locked (see [suggestion by MarcoFalke](https://github.com/bitcoin/bitcoin/pull/22383#discussion_r675069128)):
https://github.com/bitcoin/bitcoin/blob/b620b2d58a55a88ad21da70cb2000863ef17b651/src/txmempool.h#L554-L558
`CTxMemPool::get()` acquires this lock:
https://github.com/bitcoin/bitcoin/blob/b620b2d58a55a88ad21da70cb2000863ef17b651/src/txmempool.cpp#L822-L829
so we don't need to acquire any lock ourselves in `GetTransaction()`, as the other functions called in the remaining parts also don't need to have `cs_main` locked.
ACKs for top commit:
tryphe:
Concept ACK. tested 4a1b2a7ba7f804e656a8cd29d5aa80fcbd40904f but not extensively.
jnewbery:
Code review ACK 4a1b2a7ba7f804e656a8cd29d5aa80fcbd40904f
Tree-SHA512: 60e869f72e65cf72cb144be1900ea7f3d87c12f322756994f6a3ed8cd975230b36c7c90c34b60bbf41f9186f4add36decaac1d4f0d0749fb5451b3938a8aa78c
Diffstat (limited to 'src')
-rw-r--r-- | src/node/transaction.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp index 1861755aff..2a7bcc057f 100644 --- a/src/node/transaction.cpp +++ b/src/node/transaction.cpp @@ -125,8 +125,6 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock) { - LOCK(cs_main); - if (mempool && !block_index) { CTransactionRef ptx = mempool->get(hash); if (ptx) return ptx; |