github.com/PikeEcosystem/tendermint@v0.0.4/mempool/errors.go (about)

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