From 6b43d19df2ef3071a9106aa84c682ea52e62ba76 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 16 May 2022 21:34:02 -0500 Subject: [PATCH] mempool: Remove agendas from removeOrphan. This removes the treasury and auto revocations agenda flags from the unexported removeOrphan method since they are no longer used. --- internal/mempool/mempool.go | 23 +++++++++-------------- internal/mempool/mempool_test.go | 6 ++---- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index 9d085080..4d7b987f 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -395,9 +395,7 @@ var _ mining.TxSource = (*TxPool)(nil) // RemoveOrphan. See the comment for RemoveOrphan for more details. // // This function MUST be called with the mempool lock held (for writes). -func (mp *TxPool) removeOrphan(tx *dcrutil.Tx, removeRedeemers, - isTreasuryEnabled, isAutoRevocationsEnabled bool) { - +func (mp *TxPool) removeOrphan(tx *dcrutil.Tx, removeRedeemers bool) { // Nothing to do if the passed tx does not exist in the orphan pool. txHash := tx.Hash() otx, exists := mp.orphans[*txHash] @@ -433,8 +431,7 @@ func (mp *TxPool) removeOrphan(tx *dcrutil.Tx, removeRedeemers, for txOutIdx := range tx.MsgTx().TxOut { outpoint.Index = uint32(txOutIdx) for _, orphan := range mp.orphansByPrev[outpoint] { - mp.removeOrphan(orphan, true, isTreasuryEnabled, - isAutoRevocationsEnabled) + mp.removeOrphan(orphan, true) } } } @@ -451,7 +448,7 @@ func (mp *TxPool) RemoveOrphan(tx *dcrutil.Tx, isTreasuryEnabled, isAutoRevocationsEnabled bool) { mp.mtx.Lock() - mp.removeOrphan(tx, false, isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(tx, false) mp.mtx.Unlock() } @@ -466,7 +463,7 @@ func (mp *TxPool) RemoveOrphansByTag(tag Tag, isTreasuryEnabled, mp.mtx.Lock() for _, otx := range mp.orphans { if otx.tag == tag { - mp.removeOrphan(otx.tx, true, isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(otx.tx, true) numEvicted++ } } @@ -489,8 +486,7 @@ func (mp *TxPool) limitNumOrphans(isTreasuryEnabled, isAutoRevocationsEnabled bo // Remove redeemers too because the missing parents are very // unlikely to ever materialize since the orphan has already // been around more than long enough for them to be delivered. - mp.removeOrphan(otx.tx, true, isTreasuryEnabled, - isAutoRevocationsEnabled) + mp.removeOrphan(otx.tx, true) } } @@ -519,7 +515,7 @@ func (mp *TxPool) limitNumOrphans(isTreasuryEnabled, isAutoRevocationsEnabled bo for _, otx := range mp.orphans { // Don't remove redeemers in the case of a random eviction since // it is quite possible it might be needed again shortly. - mp.removeOrphan(otx.tx, false, isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(otx.tx, false) break } } @@ -600,7 +596,7 @@ func (mp *TxPool) removeOrphanDoubleSpends(tx *dcrutil.Tx, isTreasuryEnabled, msgTx := tx.MsgTx() for _, txIn := range msgTx.TxIn { for _, orphan := range mp.orphansByPrev[txIn.PreviousOutPoint] { - mp.removeOrphan(orphan, true, isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(orphan, true) } } } @@ -1964,8 +1960,7 @@ func (mp *TxPool) processOrphans(acceptedTx *dcrutil.Tx, checkTxFlags blockchain // is no way any other orphans which // redeem any of its outputs can be // accepted. Remove them. - mp.removeOrphan(tx, true, - isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(tx, true) break } @@ -1983,7 +1978,7 @@ func (mp *TxPool) processOrphans(acceptedTx *dcrutil.Tx, checkTxFlags blockchain // transactions to process so any orphans that // depend on it are handled too. acceptedTxns = append(acceptedTxns, tx) - mp.removeOrphan(tx, false, isTreasuryEnabled, isAutoRevocationsEnabled) + mp.removeOrphan(tx, false) processList = append(processList, tx) // Only one transaction for this outpoint can be diff --git a/internal/mempool/mempool_test.go b/internal/mempool/mempool_test.go index 3593a6d6..33ffbcbe 100644 --- a/internal/mempool/mempool_test.go +++ b/internal/mempool/mempool_test.go @@ -1524,8 +1524,7 @@ func TestOrphanChainRemoval(t *testing.T) { // remove redeemer flag set and ensure that only the first orphan was // removed. harness.txPool.mtx.Lock() - harness.txPool.removeOrphan(chainedTxns[1], false, noTreasury, - noAutoRevocations) + harness.txPool.removeOrphan(chainedTxns[1], false) harness.txPool.mtx.Unlock() testPoolMembership(tc, chainedTxns[1], false, false) for _, tx := range chainedTxns[2 : maxOrphans+1] { @@ -1535,8 +1534,7 @@ func TestOrphanChainRemoval(t *testing.T) { // Remove the first remaining orphan that starts the orphan chain with // the remove redeemer flag set and ensure they are all removed. harness.txPool.mtx.Lock() - harness.txPool.removeOrphan(chainedTxns[2], true, noTreasury, - noAutoRevocations) + harness.txPool.removeOrphan(chainedTxns[2], true) harness.txPool.mtx.Unlock() for _, tx := range chainedTxns[2 : maxOrphans+1] { testPoolMembership(tc, tx, false, false)