forked from taikoxyz/taiko-mono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.go
44 lines (37 loc) · 1.15 KB
/
block.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package eventindexer
import (
"context"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
// ProcessedBlock is a database model representing simple header types
// to keep track of our most recently processed block number and hash.
type ProcessedBlock struct {
ID int `json:"id"`
Height uint64 `json:"blockHeight" gorm:"column:block_height"`
Hash string `json:"hash"`
ChainID int64 `json:"chainID"`
}
// SaveProcessedBlockOpts is required to store a new block
type SaveProcessedBlockOpts struct {
Height uint64
Hash common.Hash
ChainID *big.Int
}
// ProcessedBlockRepository defines methods necessary for interacting with
// the block store.
type ProcessedBlockRepository interface {
Save(opts SaveProcessedBlockOpts) error
GetLatestBlockProcessed(chainID *big.Int) (*ProcessedBlock, error)
}
type Block struct {
ID int `json:"id"`
ChainID int64 `json:"chainID"`
BlockID int64 `json:"blockID"`
TransactedAt time.Time `json:"transactedAt"`
}
type BlockRepository interface {
Save(ctx context.Context, tx *types.Block, chainID *big.Int) error
}