diff options
author | Carl Dong <contact@carldong.me> | 2021-11-12 18:25:54 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-12-07 14:48:49 -0500 |
commit | 89bec827fdea1cedd560be85201f04e0a78aa48d (patch) | |
tree | c4cb48a2f478dd98528e000495db459ad5d49449 | |
parent | 3b1584b794499158e0df07bd1bee1b803c568614 (diff) |
Collapse the 2 cs_main locks in LoadChainstate
-rw-r--r-- | src/node/chainstate.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 7cb452a910..ce1128d9f6 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -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; + } } } |