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.

33 lines
892 B

  1. package mempool
  2. import (
  3. "crypto/sha256"
  4. "github.com/tendermint/tendermint/internal/p2p"
  5. "github.com/tendermint/tendermint/types"
  6. )
  7. // TxKeySize defines the size of the transaction's key used for indexing.
  8. const TxKeySize = sha256.Size
  9. // TxKey is the fixed length array key used as an index.
  10. func TxKey(tx types.Tx) [TxKeySize]byte {
  11. return sha256.Sum256(tx)
  12. }
  13. // TxHashFromBytes returns the hash of a transaction from raw bytes.
  14. func TxHashFromBytes(tx []byte) []byte {
  15. return types.Tx(tx).Hash()
  16. }
  17. // TxInfo are parameters that get passed when attempting to add a tx to the
  18. // mempool.
  19. type TxInfo struct {
  20. // SenderID is the internal peer ID used in the mempool to identify the
  21. // sender, storing two bytes with each transaction instead of 20 bytes for
  22. // the p2p.NodeID.
  23. SenderID uint16
  24. // SenderNodeID is the actual p2p.NodeID of the sender.
  25. SenderNodeID p2p.NodeID
  26. }