github.com/okex/exchain@v1.8.0/libs/tendermint/mempool/errors.go (about)

     1  package mempool
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/pkg/errors"
     7  )
     8  
     9  var (
    10  	// ErrTxInCache is returned to the client if we saw tx earlier
    11  	ErrTxInCache = errors.New("tx already exists in cache")
    12  	// ErrNoSuchTx is returned to the client if there hasn't target tx in mempool
    13  	ErrNoSuchTx = errors.New("no such tx in mempool")
    14  )
    15  
    16  // ErrTxTooLarge means the tx is too big to be sent in a message to other peers
    17  type ErrTxTooLarge struct {
    18  	max    int
    19  	actual int
    20  }
    21  
    22  func (e ErrTxTooLarge) Error() string {
    23  	return fmt.Sprintf("Tx too large. Max size is %d, but got %d", e.max, e.actual)
    24  }
    25  
    26  // ErrMempoolIsFull means Tendermint & an application can't handle that much load
    27  type ErrMempoolIsFull struct {
    28  	numTxs int
    29  	maxTxs int
    30  
    31  	txsBytes    int64
    32  	maxTxsBytes int64
    33  }
    34  
    35  func (e ErrMempoolIsFull) Error() string {
    36  	return fmt.Sprintf(
    37  		"mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)",
    38  		e.numTxs, e.maxTxs,
    39  		e.txsBytes, e.maxTxsBytes)
    40  }
    41  
    42  // ErrPreCheck is returned when tx is too big
    43  type ErrPreCheck struct {
    44  	Reason error
    45  }
    46  
    47  func (e ErrPreCheck) Error() string {
    48  	return e.Reason.Error()
    49  }
    50  
    51  // IsPreCheckError returns true if err is due to pre check failure.
    52  func IsPreCheckError(err error) bool {
    53  	_, ok := err.(ErrPreCheck)
    54  	return ok
    55  }