diff options
author | Carl Dong <contact@carldong.me> | 2022-03-01 16:14:12 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-05-20 11:57:51 -0400 |
commit | 04c31c1295eb4ecd42afd54b8e353cbda93d83f0 (patch) | |
tree | 1c5cd792c0dd52d0dc79cf21ba0623c12fdcfb83 /src/validation.h | |
parent | dbe45c34f8b4fd7d615f7e05ef1454798ef0c8ca (diff) | |
download | bitcoin-04c31c1295eb4ecd42afd54b8e353cbda93d83f0.tar.xz |
Add ChainstateManager::m_adjusted_time_callback
This decouples validation.cpp from netaddress.cpp (transitively,
timedata.cpp, and asmap.cpp).
This is important for libbitcoinkernel as:
- There is no reason for the consensus engine to be coupled with
netaddress, timedata, and asmap
- Users of libbitcoinkernel can now easily supply their own
std::function that provides the adjusted time.
See the src/Makefile.am changes for some satisfying removals.
Diffstat (limited to 'src/validation.h')
-rw-r--r-- | src/validation.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/validation.h b/src/validation.h index cae4ed4f14..6f4404e7ec 100644 --- a/src/validation.h +++ b/src/validation.h @@ -362,6 +362,7 @@ bool TestBlockValidity(BlockValidationState& state, CChainState& chainstate, const CBlock& block, CBlockIndex* pindexPrev, + const std::function<int64_t()>& adjusted_time_callback, bool fCheckPOW = true, bool fCheckMerkleRoot = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main); @@ -837,6 +838,8 @@ private: const CChainParams& m_chainparams; + const std::function<int64_t()> m_adjusted_time_callback; + //! Internal helper for ActivateSnapshot(). [[nodiscard]] bool PopulateAndValidateSnapshot( CChainState& snapshot_chainstate, @@ -857,7 +860,8 @@ public: using Options = ChainstateManagerOpts; explicit ChainstateManager(const Options& opts) - : m_chainparams(opts.chainparams) {}; + : m_chainparams{opts.chainparams}, + m_adjusted_time_callback{Assert(opts.adjusted_time_callback)} {}; const CChainParams& GetParams() const { return m_chainparams; } const Consensus::Params& GetConsensus() const { return m_chainparams.GetConsensus(); } |