Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
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 | ||||
// If -blockmaxsize is not given, limit to DEFAULT_MAX_GENERATED_BLOCK_SIZE | // If -blockmaxsize is not given, limit to DEFAULT_MAX_GENERATED_BLOCK_SIZE | ||||
// If only one is given, only restrict the specified resource. | // If only one is given, only restrict the specified resource. | ||||
// If both are given, restrict both. | // If both are given, restrict both. | ||||
uint64_t nMaxGeneratedBlockSize = DEFAULT_MAX_GENERATED_BLOCK_SIZE; | uint64_t nMaxGeneratedBlockSize = DEFAULT_MAX_GENERATED_BLOCK_SIZE; | ||||
if (IsArgSet("-blockmaxsize")) { | if (gArgs.IsArgSet("-blockmaxsize")) { | ||||
nMaxGeneratedBlockSize = | nMaxGeneratedBlockSize = | ||||
GetArg("-blockmaxsize", DEFAULT_MAX_GENERATED_BLOCK_SIZE); | gArgs.GetArg("-blockmaxsize", DEFAULT_MAX_GENERATED_BLOCK_SIZE); | ||||
} | } | ||||
// Limit size to between 1K and MaxBlockSize-1K for sanity: | // Limit size to between 1K and MaxBlockSize-1K for sanity: | ||||
nMaxGeneratedBlockSize = | nMaxGeneratedBlockSize = | ||||
std::max(uint64_t(1000), std::min(config.GetMaxBlockSize() - 1000, | std::max(uint64_t(1000), std::min(config.GetMaxBlockSize() - 1000, | ||||
nMaxGeneratedBlockSize)); | nMaxGeneratedBlockSize)); | ||||
return nMaxGeneratedBlockSize; | return nMaxGeneratedBlockSize; | ||||
} | } | ||||
BlockAssembler::BlockAssembler(const Config &_config) : config(&_config) { | BlockAssembler::BlockAssembler(const Config &_config) : config(&_config) { | ||||
if (IsArgSet("-blockmintxfee")) { | if (gArgs.IsArgSet("-blockmintxfee")) { | ||||
Amount n(0); | Amount n(0); | ||||
ParseMoney(GetArg("-blockmintxfee", ""), n); | ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n); | ||||
blockMinFeeRate = CFeeRate(n); | blockMinFeeRate = CFeeRate(n); | ||||
} else { | } else { | ||||
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); | blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
nMaxGeneratedBlockSize = | nMaxGeneratedBlockSize = | ||||
ComputeMaxGeneratedBlockSize(*config, chainActive.Tip()); | ComputeMaxGeneratedBlockSize(*config, chainActive.Tip()); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | BlockAssembler::CreateNewBlock(const CScript &scriptPubKeyIn) { | ||||
nHeight = pindexPrev->nHeight + 1; | nHeight = pindexPrev->nHeight + 1; | ||||
const CChainParams &chainparams = config->GetChainParams(); | const CChainParams &chainparams = config->GetChainParams(); | ||||
pblock->nVersion = | pblock->nVersion = | ||||
ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); | ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); | ||||
// -regtest only: allow overriding block.nVersion with | // -regtest only: allow overriding block.nVersion with | ||||
// -blockversion=N to test forking scenarios | // -blockversion=N to test forking scenarios | ||||
if (chainparams.MineBlocksOnDemand()) { | if (chainparams.MineBlocksOnDemand()) { | ||||
pblock->nVersion = GetArg("-blockversion", pblock->nVersion); | pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion); | ||||
} | } | ||||
pblock->nTime = GetAdjustedTime(); | pblock->nTime = GetAdjustedTime(); | ||||
nMaxGeneratedBlockSize = ComputeMaxGeneratedBlockSize(*config, pindexPrev); | nMaxGeneratedBlockSize = ComputeMaxGeneratedBlockSize(*config, pindexPrev); | ||||
nLockTimeCutoff = | nLockTimeCutoff = | ||||
(STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) | (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) | ||||
? pindexPrev->GetMedianTimePast() | ? pindexPrev->GetMedianTimePast() | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) { | ||||
pblocktemplate->vTxFees.push_back(iter->GetFee()); | pblocktemplate->vTxFees.push_back(iter->GetFee()); | ||||
pblocktemplate->vTxSigOpsCount.push_back(iter->GetSigOpCount()); | pblocktemplate->vTxSigOpsCount.push_back(iter->GetSigOpCount()); | ||||
nBlockSize += iter->GetTxSize(); | nBlockSize += iter->GetTxSize(); | ||||
++nBlockTx; | ++nBlockTx; | ||||
nBlockSigOps += iter->GetSigOpCount(); | nBlockSigOps += iter->GetSigOpCount(); | ||||
nFees += iter->GetFee(); | nFees += iter->GetFee(); | ||||
inBlock.insert(iter); | inBlock.insert(iter); | ||||
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY); | bool fPrintPriority = | ||||
gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY); | |||||
if (fPrintPriority) { | if (fPrintPriority) { | ||||
double dPriority = iter->GetPriority(nHeight); | double dPriority = iter->GetPriority(nHeight); | ||||
Amount dummy; | Amount dummy; | ||||
mempool.ApplyDeltas(iter->GetTx().GetId(), dPriority, dummy); | mempool.ApplyDeltas(iter->GetTx().GetId(), dPriority, dummy); | ||||
LogPrintf( | LogPrintf( | ||||
"priority %.1f fee %s txid %s\n", dPriority, | "priority %.1f fee %s txid %s\n", dPriority, | ||||
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(), | CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(), | ||||
iter->GetTx().GetId().ToString()); | iter->GetTx().GetId().ToString()); | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |