mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-19 05:36:15 +00:00
mempool,rpc: add removetx rpc method (#7047)
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.
This commit is contained in:
+6
-4
@@ -1,14 +1,16 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrTxInCache is returned to the client if we saw tx earlier
|
||||
ErrTxInCache = errors.New("tx already exists in cache")
|
||||
)
|
||||
// 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.
|
||||
|
||||
+6
-6
@@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -16,15 +17,14 @@ import (
|
||||
// Might we want types here ?
|
||||
type Tx []byte
|
||||
|
||||
// Key produces a fixed-length key for use in indexing.
|
||||
func (tx Tx) Key() TxKey { return sha256.Sum256(tx) }
|
||||
|
||||
// Hash computes the TMHASH hash of the wire encoded transaction.
|
||||
func (tx Tx) Hash() []byte {
|
||||
return tmhash.Sum(tx)
|
||||
}
|
||||
func (tx Tx) Hash() []byte { return tmhash.Sum(tx) }
|
||||
|
||||
// String returns the hex-encoded transaction as a string.
|
||||
func (tx Tx) String() string {
|
||||
return fmt.Sprintf("Tx{%X}", []byte(tx))
|
||||
}
|
||||
func (tx Tx) String() string { return fmt.Sprintf("Tx{%X}", []byte(tx)) }
|
||||
|
||||
// Txs is a slice of Tx.
|
||||
type Txs []Tx
|
||||
|
||||
Reference in New Issue
Block a user