github.com/badrootd/celestia-core@v0.0.0-20240305091328-aa4207a4b25d/mempool/cat/tx.go (about) 1 package cat 2 3 import ( 4 "time" 5 6 "github.com/badrootd/celestia-core/types" 7 ) 8 9 // wrappedTx defines a wrapper around a raw transaction with additional metadata 10 // that is used for indexing. With the exception of the map of peers who have 11 // seen this transaction, this struct should never be modified 12 type wrappedTx struct { 13 // these fields are immutable 14 tx types.Tx // the original transaction data 15 key types.TxKey // the transaction hash 16 height int64 // height when this transaction was initially checked (for expiry) 17 timestamp time.Time // time when transaction was entered (for TTL) 18 gasWanted int64 // app: gas required to execute this transaction 19 priority int64 // app: priority value for this transaction 20 sender string // app: assigned sender label 21 } 22 23 func newWrappedTx(tx types.Tx, key types.TxKey, height, gasWanted, priority int64, sender string) *wrappedTx { 24 return &wrappedTx{ 25 tx: tx, 26 key: key, 27 height: height, 28 timestamp: time.Now().UTC(), 29 gasWanted: gasWanted, 30 priority: priority, 31 sender: sender, 32 } 33 } 34 35 // Size reports the size of the raw transaction in bytes. 36 func (w *wrappedTx) size() int64 { return int64(len(w.tx)) }