github.com/evdatsion/aphelion-dpos-bft@v0.32.1/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  
    13  	// ErrTxTooLarge means the tx is too big to be sent in a message to other peers
    14  	ErrTxTooLarge = fmt.Errorf("Tx too large. Max size is %d", maxTxSize)
    15  )
    16  
    17  // ErrMempoolIsFull means Tendermint & an application can't handle that much load
    18  type ErrMempoolIsFull struct {
    19  	numTxs int
    20  	maxTxs int
    21  
    22  	txsBytes    int64
    23  	maxTxsBytes int64
    24  }
    25  
    26  func (e ErrMempoolIsFull) Error() string {
    27  	return fmt.Sprintf(
    28  		"mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)",
    29  		e.numTxs, e.maxTxs,
    30  		e.txsBytes, e.maxTxsBytes)
    31  }
    32  
    33  // ErrPreCheck is returned when tx is too big
    34  type ErrPreCheck struct {
    35  	Reason error
    36  }
    37  
    38  func (e ErrPreCheck) Error() string {
    39  	return e.Reason.Error()
    40  }
    41  
    42  // IsPreCheckError returns true if err is due to pre check failure.
    43  func IsPreCheckError(err error) bool {
    44  	_, ok := err.(ErrPreCheck)
    45  	return ok
    46  }