@@ -18,6 +18,7 @@ package fetcher
18
18
19
19
import (
20
20
"bytes"
21
+ "errors"
21
22
"fmt"
22
23
mrand "math/rand"
23
24
"sort"
@@ -277,29 +278,27 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
277
278
)
278
279
errs := f .addTxs (txs )
279
280
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 ()
289
287
}
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
293
293
294
- case core .ErrAlreadyKnown :
295
- duplicate ++
294
+ case errors . Is ( err , core .ErrAlreadyKnown ) :
295
+ duplicate ++
296
296
297
- case core .ErrUnderpriced , core .ErrReplaceUnderpriced :
298
- underpriced ++
297
+ case errors . Is ( err , core .ErrUnderpriced ) || errors . Is ( err , core .ErrReplaceUnderpriced ) :
298
+ underpriced ++
299
299
300
- default :
301
- otherreject ++
302
- }
300
+ default :
301
+ otherreject ++
303
302
}
304
303
added = append (added , txs [i ].Hash ())
305
304
}
0 commit comments