Skip to content

Commit 89bec82

Browse files
committed
Collapse the 2 cs_main locks in LoadChainstate
1 parent 3b1584b commit 89bec82

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/node/chainstate.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
113113
assert(chainstate->m_chain.Tip() != nullptr);
114114
}
115115
}
116-
}
117116

118-
if (!fReset) {
119-
LOCK(cs_main);
120-
auto chainstates{chainman.GetAll()};
121-
if (std::any_of(chainstates.begin(), chainstates.end(),
122-
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
123-
return ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED;
117+
if (!fReset) {
118+
auto chainstates{chainman.GetAll()};
119+
if (std::any_of(chainstates.begin(), chainstates.end(),
120+
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
121+
return ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED;
122+
}
124123
}
125124
}
126125

0 commit comments

Comments
 (0)