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

Ignore not found errors from tp.transactionsOrderedByFeeRate.Remove. #1974

Merged
merged 3 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func (tobf *TransactionsOrderedByFeeRate) Push(transaction *MempoolTransaction)
return nil
}

// ErrTransactionNotFound is returned bt tobf.TransactionsOrderedByFeeRate
var ErrTransactionNotFound = errors.New("Couldn't find transaction in mp.orderedTransactionsByFeeRate")

// Remove removes the given transaction from the set.
// Returns an error if transaction does not exist in the set, or if the given transaction does not have mass
// and fee filled in.
Expand All @@ -39,7 +42,8 @@ func (tobf *TransactionsOrderedByFeeRate) Remove(transaction *MempoolTransaction
}

if !wasFound {
return errors.Errorf("Couldn't find %s in mp.orderedTransactionsByFeeRate", transaction.TransactionID())
return errors.Wrapf(ErrTransactionNotFound,
"Couldn't find %s in mp.orderedTransactionsByFeeRate", transaction.TransactionID())
}

return tobf.RemoveAtIndex(index)
Expand All @@ -60,7 +64,7 @@ func (tobf *TransactionsOrderedByFeeRate) RemoveAtIndex(index int) error {
// while preserving the order.
func (tobf *TransactionsOrderedByFeeRate) findTransactionIndex(transaction *MempoolTransaction) (index int, wasFound bool, err error) {
if transaction.Transaction().Fee == 0 || transaction.Transaction().Mass == 0 {
return 0, false, errors.Errorf("findTxIndexInOrderedTransactionsByFeeRate expects a transaction with " +
return 0, false, errors.Errorf("findTransactionIndex expects a transaction with " +
"populated fee and mass")
}
txID := transaction.TransactionID()
Expand Down
9 changes: 8 additions & 1 deletion domain/miningmanager/mempool/transactions_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package mempool
import (
"time"

"github.com/pkg/errors"

"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/miningmanager/mempool/model"
)
Expand Down Expand Up @@ -79,7 +81,12 @@ func (tp *transactionsPool) removeTransaction(transaction *model.MempoolTransact

err := tp.transactionsOrderedByFeeRate.Remove(transaction)
if err != nil {
return err
if errors.Is(err, model.ErrTransactionNotFound) {
log.Errorf("Transaction %s not found in tp.transactionsOrderedByFeeRate. This should never happen but sometime does",
transaction.TransactionID())
} else {
return err
}
}

delete(tp.highPriorityTransactions, *transaction.TransactionID())
Expand Down