aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2019-12-12 10:28:14 -0500
committerJames O'Beirne <james.obeirne@pm.me>2020-03-17 14:03:40 -0400
commit5b690f0aae21e7d46cbefe3f5be645842ac4ae3b (patch)
treef400ff724c4d23acaff44dd9820854e00cbdafdb /src/validation.cpp
parent89cdf4d5692d396b8c7177b3918aa9dab07f9624 (diff)
refactor: move RewindBlockIndex to CChainState
This is in preparation for multiple chainstate initialization in init.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index a6b1344792..9d4cdf6eb9 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4538,26 +4538,15 @@ bool CChainState::RewindBlockIndex(const CChainParams& params)
PruneBlockIndexCandidates();
CheckBlockIndex(params.GetConsensus());
- }
- }
-
- return true;
-}
-
-bool RewindBlockIndex(const CChainParams& params) {
- if (!::ChainstateActive().RewindBlockIndex(params)) {
- return false;
- }
- LOCK(cs_main);
- if (::ChainActive().Tip() != nullptr) {
- // FlushStateToDisk can possibly read ::ChainActive(). Be conservative
- // and skip it here, we're about to -reindex-chainstate anyway, so
- // it'll get called a bunch real soon.
- BlockValidationState state;
- if (!::ChainstateActive().FlushStateToDisk(params, state, FlushStateMode::ALWAYS)) {
- LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", state.ToString());
- return false;
+ // FlushStateToDisk can possibly read ::ChainActive(). Be conservative
+ // and skip it here, we're about to -reindex-chainstate anyway, so
+ // it'll get called a bunch real soon.
+ BlockValidationState state;
+ if (!FlushStateToDisk(params, state, FlushStateMode::ALWAYS)) {
+ LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", state.ToString());
+ return false;
+ }
}
}