@@ -18,6 +18,7 @@ package fetcher
1818
1919import (
2020 "bytes"
21+ "errors"
2122 "fmt"
2223 mrand "math/rand"
2324 "sort"
@@ -277,29 +278,27 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
277278 )
278279 errs := f .addTxs (txs )
279280 for i , err := range errs {
280- if err != nil {
281- // Track the transaction hash if the price is too low for us.
282- // Avoid re-request this transaction when we receive another
283- // announcement.
284- if err == core .ErrUnderpriced || err == core .ErrReplaceUnderpriced {
285- for f .underpriced .Cardinality () >= maxTxUnderpricedSetSize {
286- f .underpriced .Pop ()
287- }
288- f .underpriced .Add (txs [i ].Hash ())
281+ // Track the transaction hash if the price is too low for us.
282+ // Avoid re-request this transaction when we receive another
283+ // announcement.
284+ if errors .Is (err , core .ErrUnderpriced ) || errors .Is (err , core .ErrReplaceUnderpriced ) {
285+ for f .underpriced .Cardinality () >= maxTxUnderpricedSetSize {
286+ f .underpriced .Pop ()
289287 }
290- // Track a few interesting failure types
291- switch err {
292- case nil : // Noop, but need to handle to not count these
288+ f .underpriced .Add (txs [i ].Hash ())
289+ }
290+ // Track a few interesting failure types
291+ switch {
292+ case err == nil : // Noop, but need to handle to not count these
293293
294- case core .ErrAlreadyKnown :
295- duplicate ++
294+ case errors . Is ( err , core .ErrAlreadyKnown ) :
295+ duplicate ++
296296
297- case core .ErrUnderpriced , core .ErrReplaceUnderpriced :
298- underpriced ++
297+ case errors . Is ( err , core .ErrUnderpriced ) || errors . Is ( err , core .ErrReplaceUnderpriced ) :
298+ underpriced ++
299299
300- default :
301- otherreject ++
302- }
300+ default :
301+ otherreject ++
303302 }
304303 added = append (added , txs [i ].Hash ())
305304 }
0 commit comments