mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 03:35:19 +00:00
Addresses one of the concerns with #7041. Provides a mechanism (via the RPC interface) to delete a single transaction, described by its hash, from the mempool. The method returns an error if the transaction cannot be found. Once the transaction is removed it remains in the cache and cannot be resubmitted until the cache is cleared or it expires from the cache.
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package types
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// ErrTxInCache is returned to the client if we saw tx earlier
|
|
var ErrTxInCache = errors.New("tx already exists in cache")
|
|
|
|
// TxKey is the fixed length array key used as an index.
|
|
type TxKey [sha256.Size]byte
|
|
|
|
// ErrTxTooLarge defines an error when a transaction is too big to be sent in a
|
|
// message to other peers.
|
|
type ErrTxTooLarge struct {
|
|
Max int
|
|
Actual int
|
|
}
|
|
|
|
func (e ErrTxTooLarge) Error() string {
|
|
return fmt.Sprintf("Tx too large. Max size is %d, but got %d", e.Max, e.Actual)
|
|
}
|
|
|
|
// ErrMempoolIsFull defines an error where Tendermint and the application cannot
|
|
// handle that much load.
|
|
type ErrMempoolIsFull struct {
|
|
NumTxs int
|
|
MaxTxs int
|
|
TxsBytes int64
|
|
MaxTxsBytes int64
|
|
}
|
|
|
|
func (e ErrMempoolIsFull) Error() string {
|
|
return fmt.Sprintf(
|
|
"mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)",
|
|
e.NumTxs,
|
|
e.MaxTxs,
|
|
e.TxsBytes,
|
|
e.MaxTxsBytes,
|
|
)
|
|
}
|
|
|
|
// ErrPreCheck defines an error where a transaction fails a pre-check.
|
|
type ErrPreCheck struct {
|
|
Reason error
|
|
}
|
|
|
|
func (e ErrPreCheck) Error() string {
|
|
return e.Reason.Error()
|
|
}
|
|
|
|
// IsPreCheckError returns true if err is due to pre check failure.
|
|
func IsPreCheckError(err error) bool {
|
|
return errors.As(err, &ErrPreCheck{})
|
|
}
|