[GetTransaction] remove unneeded cs_main lock acquire#22609
[GetTransaction] remove unneeded cs_main lock acquire#22609fanquake merged 1 commit intobitcoin:masterfrom
Conversation
|
Concept ACK. tested 4a1b2a7 but not extensively. |
|
Code review ACK 4a1b2a7
I had a bunch of other small improvements to |
Lets PR those separately. |
|
ACK (post-merge) I did some research, may as well post the results here.
So internally, leveldb is doing its own locking, which makes sense. @theStack also found this brief but useful article about leveldb locking that indicates that what we're doing is safe. As for the other things |
…quire 4a1b2a7 [GetTransaction] remove unneeded `cs_main` lock acquire (Sebastian Falbesoner) Pull request description: This PR is a follow-up to bitcoin#22383. For reading from the mempool, only `mempool.cs` needs to be locked (see [suggestion by MarcoFalke](bitcoin#22383 (comment))): 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 4a1b2a7 but not extensively. jnewbery: Code review ACK 4a1b2a7 Tree-SHA512: 60e869f72e65cf72cb144be1900ea7f3d87c12f322756994f6a3ed8cd975230b36c7c90c34b60bbf41f9186f4add36decaac1d4f0d0749fb5451b3938a8aa78c
This PR is a follow-up to #22383. For reading from the mempool, only
mempool.csneeds to be locked (see suggestion by MarcoFalke):bitcoin/src/txmempool.h
Lines 554 to 558 in b620b2d
CTxMemPool::get()acquires this lock:bitcoin/src/txmempool.cpp
Lines 822 to 829 in b620b2d
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 havecs_mainlocked.