Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions database/ffldb/whitebox_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015-2016 The btcsuite developers
// Copyright (c) 2016-2025 The Decred developers
// Copyright (c) 2016-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -41,7 +41,7 @@ var (

// loadBlocks loads the blocks contained in the testdata directory and returns
// a slice of them.
func loadBlocks(t *testing.T, dataFile string, network wire.CurrencyNet) ([]*dcrutil.Block, error) {
func loadBlocks(t *testing.T, dataFile string) ([]*dcrutil.Block, error) {
t.Helper()

// Open the file that contains the blocks for reading.
Expand Down Expand Up @@ -656,7 +656,7 @@ func TestFailureScenarios(t *testing.T) {

// Load the test blocks and save in the test context for use throughout
// the tests.
blocks, err := loadBlocks(t, blockDataFile, blockDataNet)
blocks, err := loadBlocks(t, blockDataFile)
if err != nil {
t.Errorf("loadBlocks: Unexpected error: %v", err)
return
Expand Down
5 changes: 3 additions & 2 deletions internal/blockchain/subsidy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2015-2023 The Decred developers
// Copyright (c) 2015-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -122,7 +122,8 @@ func coinbasePaysTreasuryAddress(subsidyCache *standalone.SubsidyCache, tx *dcru
// checkTreasuryBase checks to see if a given block's treasurybase correctly
// pays the treasury. This is the new function that uses the treasury base for
// the payout.
func checkTreasuryBase(subsidyCache *standalone.SubsidyCache, tx *dcrutil.Tx, height int64, voters uint16, params *chaincfg.Params) error {
func checkTreasuryBase(subsidyCache *standalone.SubsidyCache, tx *dcrutil.Tx,
height int64, voters uint16) error {
// Treasury subsidy only applies from block 2 onwards.
if height <= 1 {
return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/blockchain/validate.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015-2025 The Decred developers
// Copyright (c) 2015-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -4089,7 +4089,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block, parent *dcrutil.B
}
if isTreasuryEnabled {
err := checkTreasuryBase(b.subsidyCache, block.STransactions()[0],
node.height, node.voters, b.chainParams)
node.height, node.voters)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions internal/mempool/mempool.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015-2025 The Decred developers
// Copyright (c) 2015-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -898,7 +898,7 @@ func (mp *TxPool) findTx(txHash *chainhash.Hash) *mining.TxDesc {
// helper for maybeAcceptTransaction and maybeUnstageTransaction.
//
// This function MUST be called with the mempool lock held (for writes).
func (mp *TxPool) addTransaction(utxoView *blockchain.UtxoViewpoint, txDesc *TxDesc) {
func (mp *TxPool) addTransaction(txDesc *TxDesc) {
tx := txDesc.Tx
txHash := tx.Hash()
txType := txDesc.Type
Expand Down Expand Up @@ -1129,8 +1129,8 @@ func (mp *TxPool) FetchTransaction(txHash *chainhash.Hash) (*dcrutil.Tx, error)

// newTxDesc returns a new TxDesc instance that captures mempool state
// relevant to the provided transaction at the current time.
func (mp *TxPool) newTxDesc(utxoView *blockchain.UtxoViewpoint, tx *dcrutil.Tx,
txType stake.TxType, height int64, fee int64, totalSigOps int, txSize int64) *TxDesc {
func (mp *TxPool) newTxDesc(tx *dcrutil.Tx, txType stake.TxType, height int64,
fee int64, totalSigOps int, txSize int64) *TxDesc {

return &TxDesc{
TxDesc: mining.TxDesc{
Expand Down Expand Up @@ -1161,11 +1161,11 @@ func (mp *TxPool) maybeUnstageTransaction(txDesc *TxDesc, isTreasuryEnabled bool
// main pool or back to the stage pool. In the event of an error, the
// transaction will be discarded.
mp.removeStagedTransaction(tx)
utxoView, err := mp.fetchInputUtxos(txDesc.Tx, isTreasuryEnabled)
_, err := mp.fetchInputUtxos(txDesc.Tx, isTreasuryEnabled)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this function call can also be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would take reasoning through it to be 100% sure since it's been a while since I've been in this code, but I'm pretty sure the error is still needed because it is possible that the inputs are no longer valid. For example, unstaging happens when a new block shows up and that block might have invalidated the regular tx tree from which one of the staged transactions might be spending and therefore would no longer be valid to spend. There are other cases.

if err != nil {
return err
}
mp.addTransaction(utxoView, txDesc)
mp.addTransaction(txDesc)
}
return nil
}
Expand Down Expand Up @@ -1747,7 +1747,7 @@ func (mp *TxPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, allowHighFees,
tvi, mul, tspends)
}

txDesc := mp.newTxDesc(utxoView, tx, txType, bestHeight, txFee, totalSigOps,
txDesc := mp.newTxDesc(tx, txType, bestHeight, txFee, totalSigOps,
serializedSize)

// Tickets cannot be included in a block until all inputs have
Expand All @@ -1768,7 +1768,7 @@ func (mp *TxPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, allowHighFees,
}

// Add to transaction pool.
mp.addTransaction(utxoView, txDesc)
mp.addTransaction(txDesc)

// A regular transaction entering the mempool causes
// mempool tickets that redeem it to move to the stage pool.
Expand Down