arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/common/block.go
common/block.goRaw
 1package common
 2
 3import (
 4	"time"
 5
 6	ethCommon "github.com/ethereum/go-ethereum/common"
 7)
 8
 9// Block represents of an Ethereum block
10type Block struct {
11	EthBlockNum int64          `meddler:"eth_block_num"`
12	Timestamp   time.Time      `meddler:"timestamp,utctime"`
13	Hash        ethCommon.Hash `meddler:"hash"`
14	ParentHash  ethCommon.Hash `meddler:"-"`
15}
16
17// BlockData contains the information of a Block
18type BlockData struct {
19	Block Block
20	// Rollup
21	// L1UserTxs that were submitted in the block
22	L1UserTxs   []L1Tx
23	Batches     []BatchData
24	AddedTokens []Token
25	RollupVars  *RollupVars
26	// Auction
27	Bids                []Bid
28	Coordinators        []Coordinator
29	AuctionVars         *AuctionVars
30	WithdrawDelayerVars *WithdrawDelayerVars
31	// TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
32	// WithdrawalDelayerVars *common.WithdrawalDelayerVars
33}
34
35// BatchData contains the information of a Batch
36type BatchData struct {
37	// L1UserTxs that were forged in the batch
38	L1Batch bool // TODO: Remove once Batch.ForgeL1TxsNum is a pointer
39	// L1UserTxs        []common.L1Tx
40	L1CoordinatorTxs []L1Tx
41	L2Txs            []L2Tx
42	CreatedAccounts  []Account
43	ExitTree         []ExitInfo
44	Batch            Batch
45}
46
47// NewBatchData creates an empty BatchData with the slices initialized.
48func NewBatchData() *BatchData {
49	return &BatchData{
50		L1Batch: false,
51		// L1UserTxs:        make([]common.L1Tx, 0),
52		L1CoordinatorTxs: make([]L1Tx, 0),
53		L2Txs:            make([]L2Tx, 0),
54		CreatedAccounts:  make([]Account, 0),
55		ExitTree:         make([]ExitInfo, 0),
56		Batch:            Batch{},
57	}
58}