You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

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