bitbucket.org/number571/tendermint@v0.8.14/pkg/mempool/errors.go (about) 1 package mempool 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 var ( 9 // ErrTxInCache is returned to the client if we saw tx earlier 10 ErrTxInCache = errors.New("tx already exists in cache") 11 ) 12 13 // ErrTxTooLarge defines an error when a transaction is too big to be sent in a 14 // message to other peers. 15 type ErrTxTooLarge struct { 16 Max int 17 Actual int 18 } 19 20 func (e ErrTxTooLarge) Error() string { 21 return fmt.Sprintf("Tx too large. Max size is %d, but got %d", e.Max, e.Actual) 22 } 23 24 // ErrMempoolIsFull defines an error where Tendermint and the application cannot 25 // handle that much load. 26 type ErrMempoolIsFull struct { 27 NumTxs int 28 MaxTxs int 29 TxsBytes int64 30 MaxTxsBytes int64 31 } 32 33 func (e ErrMempoolIsFull) Error() string { 34 return fmt.Sprintf( 35 "mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)", 36 e.NumTxs, 37 e.MaxTxs, 38 e.TxsBytes, 39 e.MaxTxsBytes, 40 ) 41 } 42 43 // ErrPreCheck defines an error where a transaction fails a pre-check. 44 type ErrPreCheck struct { 45 Reason error 46 } 47 48 func (e ErrPreCheck) Error() string { 49 return e.Reason.Error() 50 } 51 52 // IsPreCheckError returns true if err is due to pre check failure. 53 func IsPreCheckError(err error) bool { 54 return errors.As(err, &ErrPreCheck{}) 55 }