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.

32 lines
849 B

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