MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / UpdateTime

Function UpdateTime

src/node/miner.cpp:70–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
71{
72 int64_t nOldTime = pblock->nTime;
73 int64_t nNewTime{std::max<int64_t>(GetMinimumTime(pindexPrev, consensusParams.DifficultyAdjustmentInterval()),
74 TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()))};
75
76 if (nOldTime < nNewTime) {
77 pblock->nTime = nNewTime;
78 }
79
80 // Updating time can change work required on testnet:
81 if (consensusParams.fPowAllowMinDifficultyBlocks) {
82 pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
83 }
84
85 return nNewTime - nOldTime;
86}
87
88void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
89{

Callers 3

NextEmptyBlockIndexFunction · 0.85
getblocktemplateFunction · 0.85
CreateNewBlockMethod · 0.85

Calls 3

GetMinimumTimeFunction · 0.85
GetNextWorkRequiredFunction · 0.85

Tested by

no test coverage detected