init: add missing cs_main lock

BlockManager::m_block_tree_db is protected by cs_main, so take the
cs_main lock while accessing it.
This commit is contained in:
Anthony Towns committed 2022-03-26 00:04:07 +10:00
1 parent 7c08d81e11
commit 0346c26fca
1 file changed
+1 -1
+1 -1
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);
}