aboutsummaryrefslogtreecommitdiff
path: root/src/validation.h
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2019-03-27 12:21:50 -0400
committerJames O'Beirne <james.obeirne@gmail.com>2019-05-16 09:06:54 -0400
commit403e677c9ebbf9744733010e6b0c2d1b182ee850 (patch)
tree3c97f958fc6b15676945d55a82794366d3097fb6 /src/validation.h
parent3ccbc376dd313fb7666471f24f6d9370914d00f3 (diff)
refactoring: IsInitialBlockDownload -> CChainState
We introduce CChainState.m_cached_finished_ibd because the static state it replaces would've been shared across all CChainState instances.
Diffstat (limited to 'src/validation.h')
-rw-r--r--src/validation.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/validation.h b/src/validation.h
index 3eece8d2b9..d4c368a99c 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -249,8 +249,6 @@ bool LoadChainTip(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_m
void UnloadBlockIndex();
/** Run an instance of the script checking thread */
void ThreadScriptCheck(int worker_num);
-/** Check whether we are doing an initial block download (synchronizing from disk or network) */
-bool IsInitialBlockDownload();
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
bool GetTransaction(const uint256& hash, CTransactionRef& tx, const Consensus::Params& params, uint256& hashBlock, const CBlockIndex* const blockIndex = nullptr);
/**
@@ -503,6 +501,14 @@ private:
*/
CCriticalSection m_cs_chainstate;
+ /**
+ * Whether this chainstate is undergoing initial block download.
+ *
+ * Mutable because we need to be able to mark IsInitialBlockDownload()
+ * const, which latches this for caching purposes.
+ */
+ mutable std::atomic<bool> m_cached_finished_ibd{false};
+
public:
//! The current chain of blockheaders we consult and build on.
//! @see CChain, CBlockIndex.
@@ -565,6 +571,9 @@ public:
void UnloadBlockIndex();
+ /** Check whether we are doing an initial block download (synchronizing from disk or network) */
+ bool IsInitialBlockDownload() const;
+
private:
bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main);