mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Collapse the 2 cs_main locks in LoadChainstate
This commit is contained in:
parent
3b1584b794
commit
89bec827fd
1 changed files with 6 additions and 7 deletions
|
@ -113,14 +113,13 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||
assert(chainstate->m_chain.Tip() != nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fReset) {
|
||||
LOCK(cs_main);
|
||||
auto chainstates{chainman.GetAll()};
|
||||
if (std::any_of(chainstates.begin(), chainstates.end(),
|
||||
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
|
||||
return ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED;
|
||||
if (!fReset) {
|
||||
auto chainstates{chainman.GetAll()};
|
||||
if (std::any_of(chainstates.begin(), chainstates.end(),
|
||||
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
|
||||
return ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue