Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show All 34 Lines | |||||
// Unconfirmed transactions in the memory pool often depend on other | // Unconfirmed transactions in the memory pool often depend on other | ||||
// transactions in the memory pool. When we select transactions from the | // transactions in the memory pool. When we select transactions from the | ||||
// pool, we select by highest priority or fee rate, so we might consider | // pool, we select by highest priority or fee rate, so we might consider | ||||
// transactions that depend on transactions that aren't yet in the block. | // transactions that depend on transactions that aren't yet in the block. | ||||
uint64_t nLastBlockTx = 0; | uint64_t nLastBlockTx = 0; | ||||
uint64_t nLastBlockSize = 0; | uint64_t nLastBlockSize = 0; | ||||
int64_t UpdateTime(CBlockHeader *pblock, const Config &config, | int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindexPrev) { | const CBlockIndex *pindexPrev) { | ||||
int64_t nOldTime = pblock->nTime; | int64_t nOldTime = pblock->nTime; | ||||
int64_t nNewTime = | int64_t nNewTime = | ||||
std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); | std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); | ||||
if (nOldTime < nNewTime) { | if (nOldTime < nNewTime) { | ||||
pblock->nTime = nNewTime; | pblock->nTime = nNewTime; | ||||
} | } | ||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
// Updating time can change work required on testnet: | // Updating time can change work required on testnet: | ||||
if (consensusParams.fPowAllowMinDifficultyBlocks) { | if (params.fPowAllowMinDifficultyBlocks) { | ||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, config); | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, params); | ||||
} | } | ||||
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 140 Lines • ▼ Show 20 Lines | BlockAssembler::CreateNewBlock(const CScript &scriptPubKeyIn) { | ||||
uint64_t nSerializeSize = | 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, chainparams.GetConsensus(), pindexPrev); | ||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, *config); | pblock->nBits = | ||||
GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus()); | |||||
pblock->nNonce = 0; | pblock->nNonce = 0; | ||||
pblocktemplate->entries[0].txSigOps = GetSigOpCountWithoutP2SH( | pblocktemplate->entries[0].txSigOps = GetSigOpCountWithoutP2SH( | ||||
*pblocktemplate->entries[0].tx, STANDARD_SCRIPT_VERIFY_FLAGS); | *pblocktemplate->entries[0].tx, STANDARD_SCRIPT_VERIFY_FLAGS); | ||||
// Copy all the transactions into the block | // Copy all the transactions into the block | ||||
// FIXME: This should be removed as it is significant overhead. | // FIXME: This should be removed as it is significant overhead. | ||||
// See T479 | // See T479 | ||||
for (const CBlockTemplateEntry &tx : pblocktemplate->entries) { | for (const CBlockTemplateEntry &tx : pblocktemplate->entries) { | ||||
▲ Show 20 Lines • Show All 493 Lines • Show Last 20 Lines |