Require CBlockIndex::GetBlockPos() to hold mutex cs_main
Summary:
consensus: don't call GetBlockPos in ReadBlockFromDisk without lock
The cs_main lock only covered the first invocation of CBlockIndex::GetBlockPos().
Use the blockPos local variable instead of calling the function twice, rename it to block_pos, and make it const
This is a backport of core#22895
Require CBlockIndex::GetBlockPos() to hold mutex cs_main
This is a partial backport of core#22932
https://github.com/bitcoin/bitcoin/pull/22932/commits/6fd4341c10b319399c58d71c4ddeae4417e337d7
Test Plan:
With clang and DEBUG:
ninja all check-all bitcoin-fuzzers
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D13031