MCPcopy Create free account
hub / github.com/ElementsProject/elements / UpdateTime

Function UpdateTime

src/node/miner.cpp:42–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
43{
44 int64_t nOldTime = pblock->nTime;
45 int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime());
46
47 if (nOldTime < nNewTime) {
48 pblock->nTime = nNewTime;
49 }
50
51 // Updating time can change work required on testnet:
52 if (consensusParams.fPowAllowMinDifficultyBlocks) {
53 pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
54 }
55
56 return nNewTime - nOldTime;
57}
58
59void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
60{

Callers 2

getblocktemplateFunction · 0.85
CreateNewBlockMethod · 0.85

Calls 3

GetAdjustedTimeFunction · 0.85
GetNextWorkRequiredFunction · 0.85
GetMedianTimePastMethod · 0.80

Tested by

no test coverage detected