Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | BlockAssembler::CreateNewBlock(const CScript &scriptPubKeyIn) { | ||||
pblock->nTime = GetAdjustedTime(); | pblock->nTime = GetAdjustedTime(); | ||||
nMedianTimePast = pindexPrev->GetMedianTimePast(); | nMedianTimePast = pindexPrev->GetMedianTimePast(); | ||||
nLockTimeCutoff = | nLockTimeCutoff = | ||||
(STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) | (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) | ||||
? nMedianTimePast | ? nMedianTimePast | ||||
: pblock->GetBlockTime(); | : pblock->GetBlockTime(); | ||||
// After the sigchecks activation we repurpose the 'sigops' tracking in | |||||
// mempool/mining to actually track sigchecks instead. (Proper SigOps will | |||||
// not need to be counted any more since it's getting deactivated.) | |||||
fUseSigChecks = IsPhononEnabled(chainparams.GetConsensus(), pindexPrev); | |||||
int nPackagesSelected = 0; | int nPackagesSelected = 0; | ||||
int nDescendantsUpdated = 0; | int nDescendantsUpdated = 0; | ||||
addPackageTxs(nPackagesSelected, nDescendantsUpdated); | addPackageTxs(nPackagesSelected, nDescendantsUpdated); | ||||
if (IsMagneticAnomalyEnabled(consensusParams, pindexPrev)) { | if (IsMagneticAnomalyEnabled(consensusParams, pindexPrev)) { | ||||
// If magnetic anomaly is enabled, we make sure transaction are | // If magnetic anomaly is enabled, we make sure transaction are | ||||
// canonically ordered. | // canonically ordered. | ||||
std::sort(std::begin(pblocktemplate->entries) + 1, | std::sort(std::begin(pblocktemplate->entries) + 1, | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | BlockAssembler::CreateNewBlock(const CScript &scriptPubKeyIn) { | ||||
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, consensusParams, pindexPrev); | UpdateTime(pblock, consensusParams, pindexPrev); | ||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); | ||||
pblock->nNonce = 0; | pblock->nNonce = 0; | ||||
pblocktemplate->entries[0].sigOpCount = GetSigOpCountWithoutP2SH( | pblocktemplate->entries[0].sigOpCount = 0; | ||||
*pblocktemplate->entries[0].tx, STANDARD_SCRIPT_VERIFY_FLAGS); | |||||
CValidationState state; | CValidationState state; | ||||
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, | if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, | ||||
BlockValidationOptions(nMaxGeneratedBlockSize) | BlockValidationOptions(nMaxGeneratedBlockSize) | ||||
.withCheckPoW(false) | .withCheckPoW(false) | ||||
.withCheckMerkleRoot(false))) { | .withCheckMerkleRoot(false))) { | ||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | ||||
__func__, | __func__, | ||||
Show All 18 Lines | for (CTxMemPool::setEntries::iterator iit = testSet.begin(); | ||||
if (inBlock.count(*iit)) { | if (inBlock.count(*iit)) { | ||||
testSet.erase(iit++); | testSet.erase(iit++); | ||||
} else { | } else { | ||||
iit++; | iit++; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
uint64_t BlockAssembler::MaxBlockSigOpsCountForSize(uint64_t blockSize) const { | |||||
return fUseSigChecks ? nMaxGeneratedBlockSigChecks | |||||
: GetMaxBlockSigOpsCount(blockSize); | |||||
} | |||||
bool BlockAssembler::TestPackage(uint64_t packageSize, | bool BlockAssembler::TestPackage(uint64_t packageSize, | ||||
int64_t packageSigOps) const { | int64_t packageSigOps) const { | ||||
auto blockSizeWithPackage = nBlockSize + packageSize; | auto blockSizeWithPackage = nBlockSize + packageSize; | ||||
if (blockSizeWithPackage >= nMaxGeneratedBlockSize) { | if (blockSizeWithPackage >= nMaxGeneratedBlockSize) { | ||||
return false; | return false; | ||||
} | } | ||||
if (nBlockSigOps + packageSigOps >= | if (nBlockSigOps + packageSigOps >= nMaxGeneratedBlockSigChecks) { | ||||
MaxBlockSigOpsCountForSize(blockSizeWithPackage)) { | |||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Perform transaction-level checks before adding to block: | * Perform transaction-level checks before adding to block: | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |