@@ -163,9 +163,6 @@ void BlockAssembler::resetBlock()
163163 // These counters do not include coinbase tx
164164 nBlockTx = 0 ;
165165 nFees = 0 ;
166-
167- lastFewTxs = 0 ;
168- blockFinished = false ;
169166}
170167
171168std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock (const CScript& scriptPubKeyIn,
@@ -204,7 +201,6 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
204201 if (!fNoMempoolTx ) {
205202 // Add transactions from mempool
206203 LOCK2 (cs_main,mempool.cs );
207- // addPriorityTxs(); !TODO: remove
208204 addPackageTxs ();
209205 }
210206
@@ -252,16 +248,6 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
252248 return std::move (pblocktemplate);
253249}
254250
255- bool BlockAssembler::isStillDependent (CTxMemPool::txiter iter)
256- {
257- for (CTxMemPool::txiter parent : mempool.GetMemPoolParents (iter)) {
258- if (!inBlock.count (parent)) {
259- return true ;
260- }
261- }
262- return false ;
263- }
264-
265251void BlockAssembler::onlyUnconfirmed (CTxMemPool::setEntries& testSet)
266252{
267253 for (CTxMemPool::setEntries::iterator iit = testSet.begin (); iit != testSet.end (); ) {
@@ -295,59 +281,6 @@ bool BlockAssembler::TestPackageFinality(const CTxMemPool::setEntries& package)
295281 return true ;
296282}
297283
298- bool BlockAssembler::TestForBlock (CTxMemPool::txiter iter)
299- {
300- // Legacy zerocoin transactions are disabled forever.
301- assert (!iter->GetSharedTx ()->ContainsZerocoins ());
302-
303- // Don't add shielded transactions if Sapling isn't active
304- const bool isShielded = iter->IsShielded ();
305- if (isShielded && sporkManager.IsSporkActive (SPORK_20_SAPLING_MAINTENANCE)) {
306- return false ;
307- }
308-
309- unsigned int nTxSize = iter->GetTxSize ();
310- if (nBlockSize + nTxSize >= nBlockMaxSize) {
311- // If the block is so close to full that no more txs will fit
312- // or if we've tried more than 50 times to fill remaining space
313- // then flag that the block is finished
314- if (nBlockSize > nBlockMaxSize - 100 || lastFewTxs > 50 ) {
315- blockFinished = true ;
316- return false ;
317- }
318- // Once we're within 1000 bytes of a full block, only look at 50 more txs
319- // to try to fill the remaining space.
320- if (nBlockSize > nBlockMaxSize - 1000 ) {
321- lastFewTxs++;
322- }
323- return false ;
324- }
325-
326- if (isShielded && nSizeShielded + nTxSize > MAX_BLOCK_SHIELDED_TXES_SIZE) {
327- return false ;
328- }
329-
330- if (nBlockSigOps + iter->GetSigOpCount () >= MAX_BLOCK_SIGOPS_CURRENT) {
331- // If the block has room for no more sig ops then
332- // flag that the block is finished
333- if (nBlockSigOps > MAX_BLOCK_SIGOPS_CURRENT - 2 ) {
334- blockFinished = true ;
335- return false ;
336- }
337- // Otherwise attempt to find another tx with fewer sigops
338- // to put in the block.
339- return false ;
340- }
341-
342- // Must check that lock times are still valid
343- // This can be removed once MTP is always enforced
344- // as long as reorgs keep the mempool consistent.
345- if (!IsFinalTx (iter->GetSharedTx (), nHeight))
346- return false ;
347-
348- return true ;
349- }
350-
351284void BlockAssembler::AddToBlock (CTxMemPool::txiter iter)
352285{
353286 pblock->vtx .emplace_back (iter->GetSharedTx ());
@@ -371,60 +304,6 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
371304 }
372305}
373306
374- void BlockAssembler::addScoreTxs ()
375- {
376- std::priority_queue<CTxMemPool::txiter, std::vector<CTxMemPool::txiter>, ScoreCompare> clearedTxs;
377- CTxMemPool::setEntries waitSet;
378- CTxMemPool::indexed_transaction_set::index<mining_score>::type::iterator mi = mempool.mapTx .get <mining_score>().begin ();
379- CTxMemPool::txiter iter;
380- while (!blockFinished && (mi != mempool.mapTx .get <mining_score>().end () || !clearedTxs.empty ())) {
381- // If no txs that were previously postponed are available to try
382- // again, then try the next highest score tx
383- if (clearedTxs.empty ()) {
384- iter = mempool.mapTx .project <0 >(mi);
385- mi++;
386- }
387- // If a previously postponed tx is available to try again, then it
388- // has higher score than all untried so far txs
389- else {
390- iter = clearedTxs.top ();
391- clearedTxs.pop ();
392- }
393-
394- // If tx already in block, skip (added by addPriorityTxs)
395- if (inBlock.count (iter)) {
396- continue ;
397- }
398-
399- // If tx is dependent on other mempool txs which haven't yet been included
400- // then put it in the waitSet
401- if (isStillDependent (iter)) {
402- waitSet.insert (iter);
403- continue ;
404- }
405-
406- // If the fee rate is below the min fee rate for mining, then we're done
407- // adding txs based on score (fee rate)
408- if (iter->GetModifiedFee () < ::minRelayTxFee.GetFee (iter->GetTxSize ()) && nBlockSize >= nBlockMinSize) {
409- return ;
410- }
411-
412- // If this tx fits in the block add it, otherwise keep looping
413- if (TestForBlock (iter)) {
414- AddToBlock (iter);
415-
416- // This tx was successfully added, so
417- // add transactions that depend on this one to the priority queue to try again
418- for (CTxMemPool::txiter child : mempool.GetMemPoolChildren (iter)) {
419- if (waitSet.count (child)) {
420- clearedTxs.push (child);
421- waitSet.erase (child);
422- }
423- }
424- }
425- }
426- }
427-
428307void BlockAssembler::UpdatePackagesForAdded (const CTxMemPool::setEntries& alreadyAdded,
429308 indexed_modified_transaction_set& mapModifiedTx)
430309{
@@ -610,78 +489,6 @@ void BlockAssembler::addPackageTxs()
610489 }
611490}
612491
613- void BlockAssembler::addPriorityTxs ()
614- {
615- // How much of the block should be dedicated to high-priority transactions,
616- // included regardless of the fees they pay
617- unsigned int nBlockPrioritySize = gArgs .GetArg (" -blockprioritysize" , DEFAULT_BLOCK_PRIORITY_SIZE);
618- nBlockPrioritySize = std::min (nBlockMaxSize, nBlockPrioritySize);
619-
620- if (nBlockPrioritySize == 0 ) {
621- return ;
622- }
623-
624- // This vector will be sorted into a priority queue:
625- std::vector<TxCoinAgePriority> vecPriority;
626- TxCoinAgePriorityCompare pricomparer;
627- std::map<CTxMemPool::txiter, double , CTxMemPool::CompareIteratorByHash> waitPriMap;
628- typedef std::map<CTxMemPool::txiter, double , CTxMemPool::CompareIteratorByHash>::iterator waitPriIter;
629- double actualPriority = -1 ;
630-
631- vecPriority.reserve (mempool.mapTx .size ());
632- for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx .begin ();
633- mi != mempool.mapTx .end (); ++mi) {
634- double dPriority = mi->GetPriority (nHeight);
635- CAmount dummy{0 };
636- mempool.ApplyDeltas (mi->GetSharedTx ()->GetHash (), dPriority, dummy);
637- vecPriority.emplace_back (TxCoinAgePriority (dPriority, mi));
638- }
639- std::make_heap (vecPriority.begin (), vecPriority.end (), pricomparer);
640-
641- CTxMemPool::txiter iter;
642- while (!vecPriority.empty () && !blockFinished) { // add a tx from priority queue to fill the blockprioritysize
643- iter = vecPriority.front ().second ;
644- actualPriority = vecPriority.front ().first ;
645- std::pop_heap (vecPriority.begin (), vecPriority.end (), pricomparer);
646- vecPriority.pop_back ();
647-
648- // If tx already in block, skip
649- if (inBlock.count (iter)) {
650- assert (false ); // shouldn't happen for priority txs
651- continue ;
652- }
653-
654- // If tx is dependent on other mempool txs which haven't yet been included
655- // then put it in the waitSet
656- if (isStillDependent (iter)) {
657- waitPriMap.insert (std::make_pair (iter, actualPriority));
658- continue ;
659- }
660-
661- // If this tx fits in the block add it, otherwise keep looping
662- if (TestForBlock (iter)) {
663- AddToBlock (iter);
664-
665- // If now that this txs is added we've surpassed our desired priority size
666- // or have dropped below the AllowFreeThreshold, then we're done adding priority txs
667- if (nBlockSize >= nBlockPrioritySize || !AllowFree (actualPriority)) {
668- return ;
669- }
670-
671- // This tx was successfully added, so
672- // add transactions that depend on this one to the priority queue to try again
673- for (CTxMemPool::txiter child : mempool.GetMemPoolChildren (iter)) {
674- waitPriIter wpiter = waitPriMap.find (child);
675- if (wpiter != waitPriMap.end ()) {
676- vecPriority.emplace_back (TxCoinAgePriority (wpiter->second ,child));
677- std::push_heap (vecPriority.begin (), vecPriority.end (), pricomparer);
678- waitPriMap.erase (wpiter);
679- }
680- }
681- }
682- }
683- }
684-
685492void BlockAssembler::appendSaplingTreeRoot ()
686493{
687494 // Update header
0 commit comments