Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (nOldTime < nNewTime) { | ||||
pblock->nTime = nNewTime; | pblock->nTime = nNewTime; | ||||
} | } | ||||
const Consensus::Params &consensusParams = | const Consensus::Params &consensusParams = | ||||
config.GetChainParams().GetConsensus(); | config.GetChainParams().GetConsensus(); | ||||
// Updating time can change work required on testnet: | // Updating time can change work required on testnet: | ||||
if (consensusParams.fPowAllowMinDifficultyBlocks) { | if (consensusParams.fPowAllowMinDifficultyBlocks) { | ||||
pblock->nBits = | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, config); | ||||
GetNextWorkRequired(pindexPrev, pblock, consensusParams); | |||||
} | } | ||||
return nNewTime - nOldTime; | return nNewTime - nOldTime; | ||||
} | } | ||||
static uint64_t ComputeMaxGeneratedBlockSize(const Config &config, | static uint64_t ComputeMaxGeneratedBlockSize(const Config &config, | ||||
const CBlockIndex *pindexPrev) { | const CBlockIndex *pindexPrev) { | ||||
// Block resource limits | // Block resource limits | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | uint64_t nSerializeSize = | ||||
GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION); | GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION); | ||||
LogPrintf("CreateNewBlock(): total size: %u txs: %u fees: %ld sigops %d\n", | LogPrintf("CreateNewBlock(): total size: %u txs: %u fees: %ld sigops %d\n", | ||||
nSerializeSize, nBlockTx, nFees, nBlockSigOps); | nSerializeSize, nBlockTx, nFees, nBlockSigOps); | ||||
// Fill in header. | // Fill in header. | ||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash(); | pblock->hashPrevBlock = pindexPrev->GetBlockHash(); | ||||
UpdateTime(pblock, *config, pindexPrev); | UpdateTime(pblock, *config, pindexPrev); | ||||
pblock->nBits = | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, *config); | ||||
GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus()); | |||||
pblock->nNonce = 0; | pblock->nNonce = 0; | ||||
pblocktemplate->vTxSigOpsCount[0] = | pblocktemplate->vTxSigOpsCount[0] = | ||||
GetSigOpCountWithoutP2SH(*pblock->vtx[0]); | GetSigOpCountWithoutP2SH(*pblock->vtx[0]); | ||||
CValidationState state; | CValidationState state; | ||||
if (!TestBlockValidity(*config, state, *pblock, pindexPrev, false, false)) { | if (!TestBlockValidity(*config, state, *pblock, pindexPrev, false, false)) { | ||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | ||||
__func__, | __func__, | ||||
▲ Show 20 Lines • Show All 438 Lines • Show Last 20 Lines |