hermez-node/common/pooll2tx.go
common/pooll2tx.goRaw
1package common
2
3import (
4 "math/big"
5 "time"
6
7 eth "github.com/ethereum/go-ethereum/common"
8 "github.com/iden3/go-iden3-crypto/babyjub"
9)
10
11// PoolL2Tx is a struct that represents a L2Tx sent by an account to the coordinator hat is waiting to be forged
12type PoolL2Tx struct {
13 Tx
14 ToBJJ babyjub.PublicKey
15 Status PoolL2TxStatus
16 RqTxCompressedData []byte // 253 bits, optional for atomic txs
17 RqTx RqTx
18 Timestamp time.Time // time when added to the tx pool
19 Signature babyjub.Signature // tx signature
20 ToEthAddr eth.Address
21 AbsoluteFee float64 // TODO add methods to calculate this value from Tx.Fee tables + priceupdater tables
22}
23
24// RqTx Transaction Data used to indicate that a transaction depends on another transaction
25type RqTx struct {
26 FromEthAddr eth.Address
27 ToEthAddr eth.Address
28 TokenID TokenID
29 Amount *big.Int
30 FeeSelector FeeSelector
31 Nonce uint64 // effective 48 bits used
32}
33
34// PoolL2TxStatus is a struct that represents the status of a L2 transaction
35type PoolL2TxStatus string
36
37const (
38 // PoolL2TxStatusPending represents a valid L2Tx that hasn't started the forging process
39 PoolL2TxStatusPending PoolL2TxStatus = "Pending"
40 // PoolL2TxStatusForging represents a valid L2Tx that has started the forging process
41 PoolL2TxStatusForging PoolL2TxStatus = "Forging"
42 // PoolL2TxStatusForged represents a L2Tx that has already been forged
43 PoolL2TxStatusForged PoolL2TxStatus = "Forged"
44 // PoolL2TxStatusInvalid represents a L2Tx that has been invalidated
45 PoolL2TxStatusInvalid PoolL2TxStatus = "Invalid"
46)