diff --git a/src/miner.h b/src/miner.h --- a/src/miner.h +++ b/src/miner.h @@ -213,6 +213,5 @@ void IncrementExtraNonce(const Config &config, CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce); -int64_t UpdateTime(CBlockHeader *pblock, const Config &config, - const CBlockIndex *pindexPrev); +int64_t UpdateTime(CBlockHeader *pblock, const CBlockIndex *pindexPrev); #endif // BITCOIN_MINER_H diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -49,8 +49,7 @@ uint64_t nLastBlockTx = 0; uint64_t nLastBlockSize = 0; -int64_t UpdateTime(CBlockHeader *pblock, const Config &config, - const CBlockIndex *pindexPrev) { +int64_t UpdateTime(CBlockHeader *pblock, const CBlockIndex *pindexPrev) { int64_t nOldTime = pblock->nTime; int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); @@ -59,14 +58,6 @@ pblock->nTime = nNewTime; } - const Consensus::Params &consensusParams = - config.GetChainParams().GetConsensus(); - - // Updating time can change work required on testnet: - if (consensusParams.fPowAllowMinDifficultyBlocks) { - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, config); - } - return nNewTime - nOldTime; } @@ -207,7 +198,7 @@ // Fill in header. pblock->hashPrevBlock = pindexPrev->GetBlockHash(); - UpdateTime(pblock, *config, pindexPrev); + UpdateTime(pblock, pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, *config); pblock->nNonce = 0; pblocktemplate->vTxSigOpsCount[0] = @@ -224,11 +215,12 @@ } int64_t nTime2 = GetTimeMicros(); - LogPrint( - BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d " - "updated descendants), validity: %.2fms (total %.2fms)\n", - 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, - 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart)); + LogPrint(BCLog::BENCH, + "CreateNewBlock() packages: %.2fms (%d packages, %d " + "updated descendants), validity: %.2fms (total %.2fms)\n", + 0.001 * (nTime1 - nTimeStart), nPackagesSelected, + nDescendantsUpdated, 0.001 * (nTime2 - nTime1), + 0.001 * (nTime2 - nTimeStart)); return std::move(pblocktemplate); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -642,7 +642,7 @@ config.GetChainParams().GetConsensus(); // Update nTime - UpdateTime(pblock, config, pindexPrev); + UpdateTime(pblock, pindexPrev); pblock->nNonce = 0; UniValue aCaps(UniValue::VARR); @@ -772,9 +772,9 @@ result.push_back( Pair("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue.GetSatoshis())); - result.push_back(Pair("longpollid", - chainActive.Tip()->GetBlockHash().GetHex() + - i64tostr(nTransactionsUpdatedLast))); + result.push_back( + Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + + i64tostr(nTransactionsUpdatedLast))); result.push_back(Pair("target", hashTarget.GetHex())); result.push_back( Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast() + 1)); @@ -991,10 +991,10 @@ UniValue result(UniValue::VOBJ); int answerFound; CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound); - result.push_back(Pair("feerate", - feeRate == CFeeRate(Amount(0)) - ? -1.0 - : ValueFromAmount(feeRate.GetFeePerK()))); + result.push_back( + Pair("feerate", feeRate == CFeeRate(Amount(0)) + ? -1.0 + : ValueFromAmount(feeRate.GetFeePerK()))); result.push_back(Pair("blocks", answerFound)); return result; }