mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-28 01:59:35 +01:00
Merge #15976: refactor: move methods under CChainState (pt. 1)
403e677c9refactoring: IsInitialBlockDownload -> CChainState (James O'Beirne)3ccbc376drefactoring: FlushStateToDisk -> CChainState (James O'Beirne)4d6688603refactoring: introduce ChainstateActive() (James O'Beirne)d7c97edeemove-only: make the CChainState interface public (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11): Parent PR: #15606 Issue: #15605 Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal --- This changeset starts moving functionality intimately related to CChainState into methods. Parameterizing these functions by a particular CChainState is necessary for the use of multiple chainstates simultaneously (e.g. for asynchronous background validation). In this change, we - make the CChainState interface public - since other units will start to invoke its methods directly, - introduce `::ChainstateActive()`, the CChainState equivalent for `::ChainActive()`, - and move `IsInitialBlockDownload()` and `FlushStateToDisk()` into methods on CChainState. Independent of assumeutxo, these changes better encapsulate chainstate behavior and allow easier use from a testing context. There are more methods that we'll move in the future, but they require other substantial changes (i.e. moving ownership of the `CCoinsView*` hierarchy into CChainState) so we'll save them for future PRs. --- The first move-only commit is most easily reviewed with `git diff ... --color-moved=dimmed_zebra`. ACKs for commit 403e67: Empact: utACK403e677c9eno need to address my nits herein Sjors: utACK403e677ryanofsky: utACK403e677c9e. Only change since previous review is removing global state comment as suggested. MarcoFalke: utACK403e677c9e, though the diff still seems a bit bloated with some unnecessary changes in the second commit. promag: utACK403e677and rebased with current [master](c7cfd20a7). Tree-SHA512: 6fcf260bb2dc201361170c0b4547405366f5f331fcc3a2bac29b24442814b7b244ca1b58aac5af716885f9a130c343b544590dff780da0bf835c7c5b3ccb2257
This commit is contained in:
@@ -259,7 +259,7 @@ void Shutdown(InitInterfaces& interfaces)
|
||||
|
||||
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
|
||||
if (pcoinsTip != nullptr) {
|
||||
FlushStateToDisk();
|
||||
::ChainstateActive().ForceFlushStateToDisk();
|
||||
}
|
||||
|
||||
// After there are no more peers/RPC left to give us new data which may generate
|
||||
@@ -275,7 +275,7 @@ void Shutdown(InitInterfaces& interfaces)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (pcoinsTip != nullptr) {
|
||||
FlushStateToDisk();
|
||||
::ChainstateActive().ForceFlushStateToDisk();
|
||||
}
|
||||
pcoinsTip.reset();
|
||||
pcoinscatcher.reset();
|
||||
@@ -1693,7 +1693,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK);
|
||||
if (!fReindex) {
|
||||
uiInterface.InitMessage(_("Pruning blockstore..."));
|
||||
PruneAndFlush();
|
||||
::ChainstateActive().PruneAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user