Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Remove unused params. #2917

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
16 changes: 5 additions & 11 deletions internal/mining/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func calcBlockCommitmentRootV1(block *wire.MsgBlock, prevScripts blockcf2.PrevSc
func createCoinbaseTx(subsidyCache *standalone.SubsidyCache,
coinbaseScript []byte, opReturnPkScript []byte, nextBlockHeight int64,
addr stdaddr.Address, voters uint16, params *chaincfg.Params,
isTreasuryEnabled, isSubsidyEnabled bool) (*dcrutil.Tx, error) {
isTreasuryEnabled, isSubsidyEnabled bool) *dcrutil.Tx {

// Coinbase transactions have no inputs, so previous outpoint is zero hash
// and max index.
Expand Down Expand Up @@ -571,7 +571,7 @@ func createCoinbaseTx(subsidyCache *standalone.SubsidyCache,
})
}

return dcrutil.NewTx(tx), nil
return dcrutil.NewTx(tx)
}

// Prior to the decentralized treasury agenda, the transaction version must
Expand Down Expand Up @@ -645,7 +645,7 @@ func createCoinbaseTx(subsidyCache *standalone.SubsidyCache,
Version: workSubsidyScriptVer,
PkScript: workSubsidyScript,
})
return dcrutil.NewTx(tx), nil
return dcrutil.NewTx(tx)
}

// createTreasuryBaseTx returns a treasurybase transaction paying an appropriate
Expand Down Expand Up @@ -841,13 +841,10 @@ func (g *BlkTmplGenerator) handleTooFewVoters(nextHeight int64,
if err != nil {
return nil, err
}
coinbaseTx, err := createCoinbaseTx(g.cfg.SubsidyCache, coinbaseScript,
coinbaseTx := createCoinbaseTx(g.cfg.SubsidyCache, coinbaseScript,
opReturnPkScript, topBlock.Height(), miningAddress,
tipHeader.Voters, g.cfg.ChainParams, isTreasuryEnabled,
isSubsidyEnabled)
if err != nil {
return nil, err
}
block.AddTransaction(coinbaseTx.MsgTx())

if isTreasuryEnabled {
Expand Down Expand Up @@ -2108,12 +2105,9 @@ nextPriorityQueueItem:
}
}

coinbaseTx, err := createCoinbaseTx(g.cfg.SubsidyCache, coinbaseScript,
coinbaseTx := createCoinbaseTx(g.cfg.SubsidyCache, coinbaseScript,
opReturnPkScript, nextBlockHeight, payToAddress, uint16(voters),
g.cfg.ChainParams, isTreasuryEnabled, isSubsidyEnabled)
if err != nil {
return nil, err
}
coinbaseTx.SetTree(wire.TxTreeRegular)

numCoinbaseSigOps := int64(g.cfg.CountSigOps(coinbaseTx, true,
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