mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#23637: Remove uncompiled MTP code
This commit is contained in:
parent
0b65f1d241
commit
536c4e1b27
@ -45,14 +45,16 @@
|
|||||||
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
|
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
|
||||||
{
|
{
|
||||||
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()) {
|
||||||
@ -373,7 +379,7 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
|
|||||||
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
|
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
|
||||||
// failedTx and avoid re-evaluation, since the re-evaluation would be using
|
// failedTx and avoid re-evaluation, since the re-evaluation would be using
|
||||||
// cached size/sigops/fee values that are not actually correct.
|
// cached size/sigops/fee values that are not actually correct.
|
||||||
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx)
|
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
|
||||||
{
|
{
|
||||||
AssertLockHeld(m_mempool.cs);
|
AssertLockHeld(m_mempool.cs);
|
||||||
|
|
||||||
@ -402,7 +408,7 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve
|
|||||||
// Each time through the loop, we compare the best transaction in
|
// Each time through the loop, we compare the best transaction in
|
||||||
// mapModifiedTxs with the next transaction in the mempool to decide what
|
// mapModifiedTxs with the next transaction in the mempool to decide what
|
||||||
// transaction package to work on next.
|
// transaction package to work on next.
|
||||||
void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated, const CBlockIndex* const pindexPrev)
|
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated, const CBlockIndex* const pindexPrev)
|
||||||
{
|
{
|
||||||
AssertLockHeld(m_mempool.cs);
|
AssertLockHeld(m_mempool.cs);
|
||||||
|
|
||||||
@ -555,7 +561,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
|
|||||||
std::vector<CTxMemPool::txiter> sortedEntries;
|
std::vector<CTxMemPool::txiter> sortedEntries;
|
||||||
SortForBlock(ancestors, sortedEntries);
|
SortForBlock(ancestors, sortedEntries);
|
||||||
|
|
||||||
for (size_t i=0; i<sortedEntries.size(); ++i) {
|
for (size_t i = 0; i < sortedEntries.size(); ++i) {
|
||||||
AddToBlock(sortedEntries[i]);
|
AddToBlock(sortedEntries[i]);
|
||||||
// Erase from the modified set, if present
|
// Erase from the modified set, if present
|
||||||
mapModifiedTx.erase(sortedEntries[i]);
|
mapModifiedTx.erase(sortedEntries[i]);
|
||||||
@ -572,13 +578,12 @@ 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;
|
||||||
}
|
}
|
||||||
++nExtraNonce;
|
++nExtraNonce;
|
||||||
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
|
unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2
|
||||||
CMutableTransaction txCoinbase(*pblock->vtx[0]);
|
CMutableTransaction txCoinbase(*pblock->vtx[0]);
|
||||||
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce));
|
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce));
|
||||||
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
|
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
|
||||||
|
@ -99,10 +99,11 @@ struct modifiedentry_iter {
|
|||||||
// This is sufficient to sort an ancestor package in an order that is valid
|
// This is sufficient to sort an ancestor package in an order that is valid
|
||||||
// to appear in a block.
|
// to appear in a block.
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user