merge bitcoin#23637: Remove uncompiled MTP code

This commit is contained in:
Kittywhiskers Van Gogh 2021-12-01 09:32:36 +01:00
parent 0b65f1d241
commit 536c4e1b27
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 32 additions and 26 deletions

View File

@ -47,12 +47,14 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
int64_t nOldTime = pblock->nTime; int64_t nOldTime = pblock->nTime;
int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime());
if (nOldTime < nNewTime) if (nOldTime < nNewTime) {
pblock->nTime = nNewTime; pblock->nTime = nNewTime;
}
// Updating time can change work required on testnet: // Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks) if (consensusParams.fPowAllowMinDifficultyBlocks) {
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
}
return nNewTime - nOldTime; return nNewTime - nOldTime;
} }
@ -123,8 +125,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
pblocktemplate.reset(new CBlockTemplate()); pblocktemplate.reset(new CBlockTemplate());
if(!pblocktemplate.get()) if (!pblocktemplate.get()) {
return nullptr; return nullptr;
}
CBlock* const pblock = &pblocktemplate->block; // pointer for convenience CBlock* const pblock = &pblocktemplate->block; // pointer for convenience
// Add dummy coinbase tx as first transaction // Add dummy coinbase tx as first transaction
@ -149,15 +152,12 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
pblock->nVersion = g_versionbitscache.ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); pblock->nVersion = g_versionbitscache.ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());
// Non-mainnet only: allow overriding block.nVersion with // Non-mainnet only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios // -blockversion=N to test forking scenarios
if (Params().NetworkIDString() != CBaseChainParams::MAIN) if (Params().NetworkIDString() != CBaseChainParams::MAIN) {
pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion); pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion);
}
pblock->nTime = GetAdjustedTime(); pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); m_lock_time_cutoff = pindexPrev->GetMedianTimePast();
nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
? nMedianTimePast
: pblock->GetBlockTime();
if (fDIP0003Active_context) { if (fDIP0003Active_context) {
for (const Consensus::LLMQParams& params : llmq::GetEnabledQuorumParams(pindexPrev)) { for (const Consensus::LLMQParams& params : llmq::GetEnabledQuorumParams(pindexPrev)) {
@ -281,8 +281,7 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
// Only test txs not already in the block // Only test txs not already in the block
if (inBlock.count(*iit)) { if (inBlock.count(*iit)) {
testSet.erase(iit++); testSet.erase(iit++);
} } else {
else {
iit++; iit++;
} }
} }
@ -290,10 +289,13 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOps) const bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOps) const
{ {
if (nBlockSize + packageSize >= nBlockMaxSize) if (nBlockSize + packageSize >= nBlockMaxSize) {
return false; return false;
if (nBlockSigOps + packageSigOps >= nBlockMaxSigOps) }
if (nBlockSigOps + packageSigOps >= nBlockMaxSigOps) {
return false; return false;
}
return true; return true;
} }
@ -303,11 +305,14 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOp
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) const bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) const
{ {
for (CTxMemPool::txiter it : package) { for (CTxMemPool::txiter it : package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) if (!IsFinalTx(it->GetTx(), nHeight, m_lock_time_cutoff)) {
return false; return false;
}
const auto& txid = it->GetTx().GetHash(); const auto& txid = it->GetTx().GetHash();
if (!m_isman.RejectConflictingBlocks() || !m_isman.IsInstantSendEnabled() || m_isman.IsLocked(txid)) continue; if (!m_isman.RejectConflictingBlocks() || !m_isman.IsInstantSendEnabled() || m_isman.IsLocked(txid)) {
continue;
}
if (!it->GetTx().vin.empty() && !m_clhandler.IsTxSafeForMining(txid)) { if (!it->GetTx().vin.empty() && !m_clhandler.IsTxSafeForMining(txid)) {
return false; return false;
@ -346,8 +351,9 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
m_mempool.CalculateDescendants(it, descendants); m_mempool.CalculateDescendants(it, descendants);
// Insert all descendants (not yet in block) into the modified set // Insert all descendants (not yet in block) into the modified set
for (CTxMemPool::txiter desc : descendants) { for (CTxMemPool::txiter desc : descendants) {
if (alreadyAdded.count(desc)) if (alreadyAdded.count(desc)) {
continue; continue;
}
++nDescendantsUpdated; ++nDescendantsUpdated;
modtxiter mit = mapModifiedTx.find(desc); modtxiter mit = mapModifiedTx.find(desc);
if (mit == mapModifiedTx.end()) { if (mit == mapModifiedTx.end()) {
@ -572,8 +578,7 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
{ {
// Update nExtraNonce // Update nExtraNonce
static uint256 hashPrevBlock; static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock) if (hashPrevBlock != pblock->hashPrevBlock) {
{
nExtraNonce = 0; nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock; hashPrevBlock = pblock->hashPrevBlock;
} }

View File

@ -101,8 +101,9 @@ struct modifiedentry_iter {
struct CompareTxIterByAncestorCount { struct CompareTxIterByAncestorCount {
bool operator()(const CTxMemPool::txiter& a, const CTxMemPool::txiter& b) const bool operator()(const CTxMemPool::txiter& a, const CTxMemPool::txiter& b) const
{ {
if (a->GetCountWithAncestors() != b->GetCountWithAncestors()) if (a->GetCountWithAncestors() != b->GetCountWithAncestors()) {
return a->GetCountWithAncestors() < b->GetCountWithAncestors(); return a->GetCountWithAncestors() < b->GetCountWithAncestors();
}
return CompareIteratorByHash()(a, b); return CompareIteratorByHash()(a, b);
} }
}; };
@ -162,7 +163,7 @@ private:
// Chain context for the block // Chain context for the block
int nHeight; int nHeight;
int64_t nLockTimeCutoff; int64_t m_lock_time_cutoff;
BlockManager& m_blockman; BlockManager& m_blockman;
CCreditPoolManager& m_cpoolman; CCreditPoolManager& m_cpoolman;