Skip to content

Commit

Permalink
internal/mempool: remove unused isTreasuryEnabled param.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored and davecgh committed Apr 7, 2022
1 parent bb84081 commit 8e45fc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internal/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ func (mp *TxPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, rateLimit,
medianTime := mp.cfg.PastMedianTime()
if !mp.cfg.Policy.AcceptNonStd {
err := checkTransactionStandard(tx, txType, nextBlockHeight,
medianTime, mp.cfg.Policy.MinRelayTxFee, isTreasuryEnabled)
medianTime, mp.cfg.Policy.MinRelayTxFee)
if err != nil {
str := fmt.Sprintf("transaction %v is not standard: %v",
txHash, err)
Expand Down
3 changes: 1 addition & 2 deletions internal/mempool/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ func isDust(txOut *wire.TxOut, minRelayTxFee dcrutil.Amount) bool {
// Note: all non-nil errors MUST be RuleError with an underlying TxRuleError
// instance.
func checkTransactionStandard(tx *dcrutil.Tx, txType stake.TxType, height int64,
medianTime time.Time, minRelayTxFee dcrutil.Amount,
isTreasuryEnabled bool) error {
medianTime time.Time, minRelayTxFee dcrutil.Amount) error {

// The transaction must be a currently supported serialize type.
msgTx := tx.MsgTx()
Expand Down
2 changes: 1 addition & 1 deletion internal/mempool/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func TestCheckTransactionStandard(t *testing.T) {
txType := stake.DetermineTxType(&test.tx, noTreasury, noAutoRevocations)
tx := dcrutil.NewTx(&test.tx)
err := checkTransactionStandard(tx, txType, test.height, medianTime,
DefaultMinRelayTxFee, noTreasury)
DefaultMinRelayTxFee)
if err == nil && test.isStandard {
// Test passes since function returned standard for a
// transaction which is intended to be standard.
Expand Down
20 changes: 10 additions & 10 deletions internal/mining/mining_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (p *fakeTxSource) fetchRedeemers(outpoints map[wire.OutPoint]*dcrutil.Tx,
}

// addOrphan adds the passed orphan transaction to the orphan pool.
func (p *fakeTxSource) addOrphan(tx *dcrutil.Tx, isTreasuryEnabled bool) {
func (p *fakeTxSource) addOrphan(tx *dcrutil.Tx) {
p.orphans[*tx.Hash()] = tx
for _, txIn := range tx.MsgTx().TxIn {
if _, exists := p.orphansByPrev[txIn.PreviousOutPoint]; !exists {
Expand All @@ -438,7 +438,7 @@ func (p *fakeTxSource) addOrphan(tx *dcrutil.Tx, isTreasuryEnabled bool) {
}

// removeOrphan removes the passed orphan transaction from the orphan pool.
func (p *fakeTxSource) removeOrphan(tx *dcrutil.Tx, removeRedeemers bool, isTreasuryEnabled bool) {
func (p *fakeTxSource) removeOrphan(tx *dcrutil.Tx, removeRedeemers bool) {
// Nothing to do if the passed tx does not exist in the orphan pool.
txHash := tx.Hash()
tx, exists := p.orphans[*txHash]
Expand Down Expand Up @@ -466,7 +466,7 @@ func (p *fakeTxSource) removeOrphan(tx *dcrutil.Tx, removeRedeemers bool, isTrea
for txOutIdx := range tx.MsgTx().TxOut {
prevOut.Index = uint32(txOutIdx)
for _, orphan := range p.orphansByPrev[prevOut] {
p.removeOrphan(orphan, true, isTreasuryEnabled)
p.removeOrphan(orphan, true)
}
}
}
Expand All @@ -480,11 +480,11 @@ func (p *fakeTxSource) removeOrphan(tx *dcrutil.Tx, removeRedeemers bool, isTrea
// to removing all orphans which rely on them, recursively. This is necessary
// when a transaction is added to the main pool because it may spend outputs
// that orphans also spend.
func (p *fakeTxSource) removeOrphanDoubleSpends(tx *dcrutil.Tx, isTreasuryEnabled bool) {
func (p *fakeTxSource) removeOrphanDoubleSpends(tx *dcrutil.Tx) {
msgTx := tx.MsgTx()
for _, txIn := range msgTx.TxIn {
for _, orphan := range p.orphansByPrev[txIn.PreviousOutPoint] {
p.removeOrphan(orphan, true, isTreasuryEnabled)
p.removeOrphan(orphan, true)
}
}
}
Expand Down Expand Up @@ -839,7 +839,7 @@ func (p *fakeTxSource) processOrphans(acceptedTx *dcrutil.Tx, isTreasuryEnabled,
if err != nil {
// The orphan is now invalid, so there is no way any other orphans which
// redeem any of its outputs can be accepted. Remove them.
p.removeOrphan(tx, true, isTreasuryEnabled)
p.removeOrphan(tx, true)
break
}

Expand All @@ -855,7 +855,7 @@ func (p *fakeTxSource) processOrphans(acceptedTx *dcrutil.Tx, isTreasuryEnabled,
// remove it from the orphan pool, and add it to the list of transactions to
// process so any orphans that depend on it are handled too.
acceptedTxns = append(acceptedTxns, tx)
p.removeOrphan(tx, false, isTreasuryEnabled)
p.removeOrphan(tx, false)
processList = append(processList, tx)

// Only one transaction for this outpoint can be accepted, so the rest are
Expand All @@ -867,9 +867,9 @@ func (p *fakeTxSource) processOrphans(acceptedTx *dcrutil.Tx, isTreasuryEnabled,

// Recursively remove any orphans that also redeem any outputs redeemed by the
// accepted transactions since those are now definitive double spends.
p.removeOrphanDoubleSpends(acceptedTx, isTreasuryEnabled)
p.removeOrphanDoubleSpends(acceptedTx)
for _, tx := range acceptedTxns {
p.removeOrphanDoubleSpends(tx, isTreasuryEnabled)
p.removeOrphanDoubleSpends(tx)
}

return acceptedTxns
Expand Down Expand Up @@ -901,7 +901,7 @@ func (p *fakeTxSource) ProcessTransaction(tx *dcrutil.Tx) ([]*dcrutil.Tx, error)
}

// Add the orphan transaction to the tx source.
p.addOrphan(tx, isTreasuryEnabled)
p.addOrphan(tx)

return nil, err
}
Expand Down

0 comments on commit 8e45fc5

Please sign in to comment.