Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show All 36 Lines | |||||
// pool, we select by highest fee rate of a transaction combined with all | // pool, we select by highest fee rate of a transaction combined with all | ||||
// its ancestors. | // its ancestors. | ||||
uint64_t nLastBlockTx = 0; | uint64_t nLastBlockTx = 0; | ||||
uint64_t nLastBlockSize = 0; | uint64_t nLastBlockSize = 0; | ||||
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params ¶ms, | int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindexPrev) { | const CBlockIndex *pindexPrev) { | ||||
int64_t tooEarlyTime = pindexPrev->GetMedianTimePast(); | |||||
if (IsPhononEnabled(params, pindexPrev)) { | |||||
tooEarlyTime = std::max(tooEarlyTime, pindexPrev->GetBlockTime()); | |||||
} | |||||
int64_t nOldTime = pblock->nTime; | int64_t nOldTime = pblock->nTime; | ||||
int64_t nNewTime = | int64_t nNewTime = | ||||
std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); | std::max({nOldTime, tooEarlyTime + 1, GetAdjustedTime()}); | ||||
if (nOldTime < nNewTime) { | |||||
pblock->nTime = nNewTime; | pblock->nTime = nNewTime; | ||||
} | |||||
// Updating time can change work required on testnet: | // Updating time can change work required on testnet: | ||||
if (params.fPowAllowMinDifficultyBlocks) { | if (params.fPowAllowMinDifficultyBlocks) { | ||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, params); | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, params); | ||||
} | } | ||||
return nNewTime - nOldTime; | return nNewTime - nOldTime; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 503 Lines • Show Last 20 Lines |