mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
types: move mempool error for consistency (#6875)
This is a little change just to make things more consistent ahead of the 0.35 release.
This commit is contained in:
55
types/mempool.go
Normal file
55
types/mempool.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrTxInCache is returned to the client if we saw tx earlier
|
||||
ErrTxInCache = errors.New("tx already exists in cache")
|
||||
)
|
||||
|
||||
// ErrTxTooLarge defines an error when a transaction is too big to be sent in a
|
||||
// message to other peers.
|
||||
type ErrTxTooLarge struct {
|
||||
Max int
|
||||
Actual int
|
||||
}
|
||||
|
||||
func (e ErrTxTooLarge) Error() string {
|
||||
return fmt.Sprintf("Tx too large. Max size is %d, but got %d", e.Max, e.Actual)
|
||||
}
|
||||
|
||||
// ErrMempoolIsFull defines an error where Tendermint and the application cannot
|
||||
// handle that much load.
|
||||
type ErrMempoolIsFull struct {
|
||||
NumTxs int
|
||||
MaxTxs int
|
||||
TxsBytes int64
|
||||
MaxTxsBytes int64
|
||||
}
|
||||
|
||||
func (e ErrMempoolIsFull) Error() string {
|
||||
return fmt.Sprintf(
|
||||
"mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)",
|
||||
e.NumTxs,
|
||||
e.MaxTxs,
|
||||
e.TxsBytes,
|
||||
e.MaxTxsBytes,
|
||||
)
|
||||
}
|
||||
|
||||
// ErrPreCheck defines an error where a transaction fails a pre-check.
|
||||
type ErrPreCheck struct {
|
||||
Reason error
|
||||
}
|
||||
|
||||
func (e ErrPreCheck) Error() string {
|
||||
return e.Reason.Error()
|
||||
}
|
||||
|
||||
// IsPreCheckError returns true if err is due to pre check failure.
|
||||
func IsPreCheckError(err error) bool {
|
||||
return errors.As(err, &ErrPreCheck{})
|
||||
}
|
||||
Reference in New Issue
Block a user