Files
tendermint/mempool/tx.go
Aleksandr Bezobchuk 7ec123c968 improvement: update TxInfo (#6529)
Remove `Context` from the `TxInfo` type and instead require the caller to pass a `Context` to `CheckTx` which is idiomatic.

closes: #6497
2021-06-02 13:53:57 +00:00

34 lines
883 B
Go

package mempool
import (
"crypto/sha256"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/types"
)
// TxKeySize defines the size of the transaction's key used for indexing.
const TxKeySize = sha256.Size
// TxKey is the fixed length array key used as an index.
func TxKey(tx types.Tx) [TxKeySize]byte {
return sha256.Sum256(tx)
}
// TxHashFromBytes returns the hash of a transaction from raw bytes.
func TxHashFromBytes(tx []byte) []byte {
return types.Tx(tx).Hash()
}
// TxInfo are parameters that get passed when attempting to add a tx to the
// mempool.
type TxInfo struct {
// SenderID is the internal peer ID used in the mempool to identify the
// sender, storing two bytes with each transaction instead of 20 bytes for
// the p2p.NodeID.
SenderID uint16
// SenderNodeID is the actual p2p.NodeID of the sender.
SenderNodeID p2p.NodeID
}