Merge bitcoin/bitcoin#24672: init: add missing cs_main lock

0346c26fca init: add missing cs_main lock (Anthony Towns)

Pull request description:

  `BlockManager::m_block_tree_db` is protected by `cs_main`, so take the
  `cs_main` lock while accessing it.

ACKs for top commit:
  jonatack:
    Code review ACK 0346c26fca

Tree-SHA512: d6dff0b2d58871c7fbb281558b59fa9ad26fa75b3ceca9232277fc49ab795325e5ac3d266db49e7bda33da6de0b014b1bdebdf2c2c4347d43e50c0433a2cf06c
This commit is contained in:
MarcoFalke 2022-03-25 16:20:50 +01:00
commit f10b24ad29
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -1541,7 +1541,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// ********************************************************* Step 8: start indexers
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
if (const auto error{CheckLegacyTxindex(*Assert(chainman.m_blockman.m_block_tree_db))}) {
if (const auto error{WITH_LOCK(cs_main, return CheckLegacyTxindex(*Assert(chainman.m_blockman.m_block_tree_db)))}) {
return InitError(*error);
}