github.com/number571/tendermint@v0.34.11-gost/internal/mempool/tx.go (about)

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