mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
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.
This commit is contained in:
@@ -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(); }
|
||||
|
||||
Reference in New Issue
Block a user