aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2021-11-12 18:25:54 -0500
committerCarl Dong <contact@carldong.me>2021-12-07 14:48:49 -0500
commit89bec827fdea1cedd560be85201f04e0a78aa48d (patch)
treec4cb48a2f478dd98528e000495db459ad5d49449
parent3b1584b794499158e0df07bd1bee1b803c568614 (diff)
Collapse the 2 cs_main locks in LoadChainstate
-rw-r--r--src/node/chainstate.cpp13
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;
+ }
}
}