arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/db/l2db/views.go
db/l2db/views.goRaw
 1package l2db
 2
 3import (
 4	"math/big"
 5	"time"
 6
 7	ethCommon "github.com/ethereum/go-ethereum/common"
 8	"github.com/hermeznetwork/hermez-node/common"
 9	"github.com/iden3/go-iden3-crypto/babyjub"
10)
11
12// PoolL2TxWrite holds the necessary data to perform inserts in tx_pool
13type PoolL2TxWrite struct {
14	TxID        common.TxID           `meddler:"tx_id"`
15	FromIdx     common.Idx            `meddler:"from_idx"`
16	ToIdx       *common.Idx           `meddler:"to_idx"`
17	ToEthAddr   *ethCommon.Address    `meddler:"to_eth_addr"`
18	ToBJJ       *babyjub.PublicKey    `meddler:"to_bjj"`
19	TokenID     common.TokenID        `meddler:"token_id"`
20	Amount      *big.Int              `meddler:"amount,bigint"`
21	AmountFloat float64               `meddler:"amount_f"`
22	Fee         common.FeeSelector    `meddler:"fee"`
23	Nonce       common.Nonce          `meddler:"nonce"`
24	State       common.PoolL2TxState  `meddler:"state"`
25	Signature   babyjub.SignatureComp `meddler:"signature"`
26	RqFromIdx   *common.Idx           `meddler:"rq_from_idx"`
27	RqToIdx     *common.Idx           `meddler:"rq_to_idx"`
28	RqToEthAddr *ethCommon.Address    `meddler:"rq_to_eth_addr"`
29	RqToBJJ     *babyjub.PublicKey    `meddler:"rq_to_bjj"`
30	RqTokenID   *common.TokenID       `meddler:"rq_token_id"`
31	RqAmount    *big.Int              `meddler:"rq_amount,bigintnull"`
32	RqFee       *common.FeeSelector   `meddler:"rq_fee"`
33	RqNonce     *common.Nonce         `meddler:"rq_nonce"`
34	Type        common.TxType         `meddler:"tx_type"`
35}
36
37// PoolL2TxRead represents a L2 Tx pool with extra metadata used by the API
38type PoolL2TxRead struct {
39	TxID        common.TxID           `meddler:"tx_id"`
40	FromIdx     common.Idx            `meddler:"from_idx"`
41	ToIdx       *common.Idx           `meddler:"to_idx"`
42	ToEthAddr   *ethCommon.Address    `meddler:"to_eth_addr"`
43	ToBJJ       *babyjub.PublicKey    `meddler:"to_bjj"`
44	Amount      *big.Int              `meddler:"amount,bigint"`
45	Fee         common.FeeSelector    `meddler:"fee"`
46	Nonce       common.Nonce          `meddler:"nonce"`
47	State       common.PoolL2TxState  `meddler:"state"`
48	Signature   babyjub.SignatureComp `meddler:"signature"`
49	RqFromIdx   *common.Idx           `meddler:"rq_from_idx"`
50	RqToIdx     *common.Idx           `meddler:"rq_to_idx"`
51	RqToEthAddr *ethCommon.Address    `meddler:"rq_to_eth_addr"`
52	RqToBJJ     *babyjub.PublicKey    `meddler:"rq_to_bjj"`
53	RqTokenID   *common.TokenID       `meddler:"rq_token_id"`
54	RqAmount    *big.Int              `meddler:"rq_amount,bigintnull"`
55	RqFee       *common.FeeSelector   `meddler:"rq_fee"`
56	RqNonce     *common.Nonce         `meddler:"rq_nonce"`
57	Type        common.TxType         `meddler:"tx_type"`
58	// Extra read fileds
59	BatchNum         *common.BatchNum  `meddler:"batch_num"`
60	Timestamp        time.Time         `meddler:"timestamp,utctime"`
61	TotalItems       int               `meddler:"total_items"`
62	TokenID          common.TokenID    `meddler:"token_id"`
63	TokenEthBlockNum int64             `meddler:"eth_block_num"`
64	TokenEthAddr     ethCommon.Address `meddler:"eth_addr"`
65	TokenName        string            `meddler:"name"`
66	TokenSymbol      string            `meddler:"symbol"`
67	TokenDecimals    uint64            `meddler:"decimals"`
68	TokenUSD         *float64          `meddler:"usd"`
69	TokenUSDUpdate   *time.Time        `meddler:"usd_update"`
70}