diff --git a/src/miner.h b/src/miner.h --- a/src/miner.h +++ b/src/miner.h @@ -159,9 +159,6 @@ const CTxMemPool *mempool; - // Variables used for addPriorityTxs - int lastFewTxs; - public: struct Options { Options(); @@ -196,20 +193,6 @@ void addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); - /** Enum for the results from TestForBlock */ - enum class TestForBlockResult : uint8_t { - TXFits = 0, - TXCantFit = 1, - BlockFinished = 3, - }; - - // helper function for addPriorityTxs - /** Test if tx will still "fit" in the block */ - TestForBlockResult TestForBlock(CTxMemPool::txiter iter); - /** Test if tx still has unconfirmed parents not yet in block */ - bool isStillDependent(CTxMemPool::txiter iter) - EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); - // helper functions for addPackageTxs() /** Remove confirmed (inBlock) entries from given set */ void onlyUnconfirmed(CTxMemPool::setEntries &testSet); diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -34,8 +34,8 @@ // Unconfirmed transactions in the memory pool often depend on other // transactions in the memory pool. When we select transactions from the -// 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. +// pool, we select by highest fee rate of a transaction combined with all +// its ancestors. uint64_t nLastBlockTx = 0; uint64_t nLastBlockSize = 0; @@ -111,8 +111,6 @@ // These counters do not include coinbase tx. nBlockTx = 0; nFees = Amount::zero(); - - lastFewTxs = 0; } std::unique_ptr @@ -237,15 +235,6 @@ return std::move(pblocktemplate); } -bool BlockAssembler::isStillDependent(CTxMemPool::txiter iter) { - for (CTxMemPool::txiter parent : mempool->GetMemPoolParents(iter)) { - if (!inBlock.count(parent)) { - return true; - } - } - return false; -} - void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries &testSet) { for (CTxMemPool::setEntries::iterator iit = testSet.begin(); iit != testSet.end();) { @@ -300,49 +289,6 @@ return true; } -BlockAssembler::TestForBlockResult -BlockAssembler::TestForBlock(CTxMemPool::txiter it) { - auto blockSizeWithTx = - nBlockSize + ::GetSerializeSize(it->GetTx(), PROTOCOL_VERSION); - if (blockSizeWithTx >= nMaxGeneratedBlockSize) { - if (nBlockSize > nMaxGeneratedBlockSize - 100 || lastFewTxs > 50) { - return TestForBlockResult::BlockFinished; - } - - if (nBlockSize > nMaxGeneratedBlockSize - 1000) { - lastFewTxs++; - } - - return TestForBlockResult::TXCantFit; - } - - auto maxBlockSigOps = GetMaxBlockSigOpsCount(blockSizeWithTx); - if (nBlockSigOps + it->GetSigOpCount() >= maxBlockSigOps) { - // If the block has room for no more sig ops then flag that the block is - // finished. - // TODO: We should consider adding another transaction that isn't very - // dense in sigops instead of bailing out so easily. - if (nBlockSigOps > maxBlockSigOps - 2) { - return TestForBlockResult::BlockFinished; - } - - // Otherwise attempt to find another tx with fewer sigops to put in the - // block. - return TestForBlockResult::TXCantFit; - } - - // Must check that lock times are still valid. This can be removed once MTP - // is always enforced as long as reorgs keep the mempool consistent. - CValidationState state; - if (!ContextualCheckTransaction(chainparams.GetConsensus(), it->GetTx(), - state, nHeight, nLockTimeCutoff, - nMedianTimePast)) { - return TestForBlockResult::TXCantFit; - } - - return TestForBlockResult::TXFits; -} - void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) { pblocktemplate->entries.emplace_back(iter->GetSharedTx(), iter->GetFee(), iter->GetTxSize(),