This PR reduces the cs_main lock scope in getblockheader RPC.
Avoid permanent cs_main lock in getblockheader #12153
pull promag wants to merge 1 commits into bitcoin:master from promag:2018-01-getblockheader changing 1 files +9 −4-
promag commented at 2:26 PM on January 11, 2018: member
- promag force-pushed on Jan 11, 2018
- fanquake added the label RPC/REST/ZMQ on Jan 11, 2018
- promag force-pushed on Jan 11, 2018
- promag force-pushed on Jan 12, 2018
- promag force-pushed on Jan 12, 2018
- promag force-pushed on Jan 15, 2018
-
ryanofsky commented at 10:33 PM on February 5, 2018: contributor
utACK last commit only 5e924f4d22a16b0c46d4c6cb19877892331d41fa (previous commits are from base PR)
- MarcoFalke added the label Needs rebase on Jun 6, 2018
- promag force-pushed on Jun 10, 2018
- promag force-pushed on Jun 10, 2018
- DrahtBot removed the label Needs rebase on Jun 11, 2018
- DrahtBot cross-referenced this on Jun 14, 2018 from issue Consistently validate txid / blockhash length and encoding in rpc calls by Empact
- DrahtBot cross-referenced this on Jul 6, 2018 from issue Trivial: delete "to" in comment by YutakaNakasone
- DrahtBot closed this on Aug 2, 2018
- DrahtBot reopened this on Aug 2, 2018
- DrahtBot cross-referenced this on Aug 10, 2018 from issue Track best-possible-headers (TheBlueMatt) by Sjors
- DrahtBot cross-referenced this on Sep 10, 2018 from issue [RPC] decodeblock by instagibbs
- DrahtBot cross-referenced this on Sep 21, 2018 from issue rpc: Remove cs_main lock from blockToJSON and blockheaderToJSON by promag
- DrahtBot added the label Needs rebase on Sep 24, 2018
- DrahtBot added the label Up for grabs on Jan 3, 2019
- DrahtBot closed this on Jan 3, 2019
- fanquake reopened this on Jan 4, 2019
- fanquake removed the label Up for grabs on Jan 4, 2019
- promag force-pushed on Jan 4, 2019
-
promag commented at 12:35 PM on January 4, 2019: member
Rebased.
- fanquake removed the label Needs rebase on Jan 4, 2019
- bitcoin deleted a comment on Jan 4, 2019
- bitcoin deleted a comment on Jan 4, 2019
- bitcoin deleted a comment on Jan 4, 2019
- bitcoin deleted a comment on Jan 4, 2019
-
in src/rpc/blockchain.cpp:761 in 4572a3901f outdated
761 | + const CBlockIndex* pblockindex; 762 | + const CBlockIndex* tip; 763 | + { 764 | + LOCK(cs_main); 765 | + pblockindex = LookupBlockIndex(hash); 766 | + if (!pblockindex) {
MarcoFalke commented at 1:09 PM on January 4, 2019:nit: Can leave this out of the cs_main lock to avoid unnecessary indentation and changes?
promag commented at 1:17 PM on January 4, 2019:Yes indeed better.
promag commented at 3:01 PM on January 4, 2019:Done.
rpc: Avoid permanent cs_main lock in getblockheader f12e1d0b51promag force-pushed on Jan 4, 2019MarcoFalke commented at 3:08 PM on January 4, 2019: memberutACK f12e1d0b5117e3688f52a25ed0170d76ecdbf233
ryanofsky approvedryanofsky commented at 4:38 PM on January 4, 2019: contributorutACK f12e1d0b5117e3688f52a25ed0170d76ecdbf233. No change since last review other than rebase.
MarcoFalke added this to the milestone 0.18.0 on Jan 5, 2019laanwj commented at 2:11 PM on January 7, 2019: memberSo to be clear: this is can be done, because it is safe to access the fields on the CBlockIndex instance without the lock?
jnewbery commented at 9:27 PM on January 7, 2019: memberutACK f12e1d0b5117e3688f52a25ed0170d76ecdbf233.
Do you intend to do the same for
getblock? Not holding cs_main while reading a block from disk and serializing into json seems like a big win.laanwj merged this on Jan 8, 2019laanwj closed this on Jan 8, 2019laanwj referenced this in commit 29a9f07743 on Jan 8, 2019promag deleted the branch on Jan 8, 2019promag cross-referenced this on May 2, 2019 from issue rpc: Serialize in getblock without cs_main by MarcoFalkeLarryRuane referenced this in commit 4b3f1d8190 on Apr 29, 2021LarryRuane cross-referenced this on May 4, 2021 from issue Bitcoin 0.18 locking PRs by LarryRuaneLarryRuane referenced this in commit 7a4a025b06 on Jun 1, 2021Munkybooty referenced this in commit f3474f2102 on Aug 20, 2021Munkybooty referenced this in commit 512b959152 on Aug 20, 2021Munkybooty referenced this in commit a94fb9395d on Aug 21, 2021Munkybooty referenced this in commit d69fde57c6 on Aug 23, 2021Munkybooty referenced this in commit 2c2eba6629 on Aug 24, 2021Munkybooty referenced this in commit 314e1f4fb3 on Aug 24, 2021UdjinM6 referenced this in commit df08b0a6e6 on Aug 24, 2021Munkybooty referenced this in commit 60d7fd708c on Aug 24, 2021bitcoin locked this on Dec 16, 2021ContributorsLabelsMilestone
0.18.0
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC