hermez-node/common/block.go
common/block.goRaw
1package common
2
3import (
4 "math/big"
5 "time"
6
7 ethCommon "github.com/ethereum/go-ethereum/common"
8)
9
10// Block represents of an Ethereum block
11type Block struct {
12 EthBlockNum int64 `meddler:"eth_block_num"`
13 Timestamp time.Time `meddler:"timestamp,utctime"`
14 Hash ethCommon.Hash `meddler:"hash"`
15 ParentHash ethCommon.Hash `meddler:"-"`
16}
17
18// RollupData contains information returned by the Rollup smart contract
19type RollupData struct {
20 // L1UserTxs that were submitted in the block
21 L1UserTxs []L1Tx
22 Batches []BatchData
23 AddedTokens []Token
24 Withdrawals []WithdrawInfo
25 Vars *RollupVariables
26}
27
28// NewRollupData creates an empty RollupData with the slices initialized.
29func NewRollupData() RollupData {
30 return RollupData{
31 L1UserTxs: make([]L1Tx, 0),
32 Batches: make([]BatchData, 0),
33 AddedTokens: make([]Token, 0),
34 Withdrawals: make([]WithdrawInfo, 0),
35 Vars: nil,
36 }
37}
38
39// AuctionData contains information returned by the Action smart contract
40type AuctionData struct {
41 Bids []Bid
42 Coordinators []Coordinator
43 Vars *AuctionVariables
44}
45
46// NewAuctionData creates an empty AuctionData with the slices initialized.
47func NewAuctionData() AuctionData {
48 return AuctionData{
49 Bids: make([]Bid, 0),
50 Coordinators: make([]Coordinator, 0),
51 Vars: nil,
52 }
53}
54
55// WDelayerTransfer represents a transfer (either deposit or withdrawal) in the
56// WDelayer smart contract
57type WDelayerTransfer struct {
58 Owner ethCommon.Address
59 Token ethCommon.Address
60 Amount *big.Int
61 // TxHash ethCommon.Hash // hash of the transaction in which the wdelayer transfer happened
62}
63
64// WDelayerData contains information returned by the WDelayer smart contract
65type WDelayerData struct {
66 Vars *WDelayerVariables
67 Deposits []WDelayerTransfer
68 DepositsByTxHash map[ethCommon.Hash]*WDelayerTransfer
69 Withdrawals []WDelayerTransfer
70}
71
72// NewWDelayerData creates an empty WDelayerData.
73func NewWDelayerData() WDelayerData {
74 return WDelayerData{
75 Vars: nil,
76 Deposits: make([]WDelayerTransfer, 0),
77 DepositsByTxHash: make(map[ethCommon.Hash]*WDelayerTransfer),
78 Withdrawals: make([]WDelayerTransfer, 0),
79 }
80}
81
82// BlockData contains the information of a Block
83type BlockData struct {
84 Block Block
85 Rollup RollupData
86 Auction AuctionData
87 WDelayer WDelayerData
88 // TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
89 // WithdrawalDelayerVars *common.WithdrawalDelayerVars
90}