forked from 0xPolygonHermez/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforkid.go
53 lines (45 loc) · 1.46 KB
/
forkid.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
45
46
47
48
49
50
51
52
53
package state
import (
"context"
"github.com/jackc/pgx/v4"
)
const (
// FORKID_BLUEBERRY is the fork id 4
FORKID_BLUEBERRY = 4
// FORKID_DRAGONFRUIT is the fork id 5
FORKID_DRAGONFRUIT = 5
// FORKID_INCABERRY is the fork id 6
FORKID_INCABERRY = 6
// FORKID_ETROG is the fork id 7
FORKID_ETROG = 7
// FORKID_ELDERBERRY is the fork id 8
FORKID_ELDERBERRY = 8
// FORKID_ELDERBERRY_2 is the fork id 9
FORKID_ELDERBERRY_2 = 9
// FORKID_FEIJOA is the fork id 10
FORKID_FEIJOA = 10
)
// ForkIDInterval is a fork id interval
type ForkIDInterval struct {
FromBatchNumber uint64
ToBatchNumber uint64
ForkId uint64
Version string
BlockNumber uint64
}
// UpdateForkIDIntervalsInMemory updates the forkID intervals in memory
func (s *State) UpdateForkIDIntervalsInMemory(intervals []ForkIDInterval) {
s.storage.UpdateForkIDIntervalsInMemory(intervals)
}
// AddForkIDInterval updates the forkID intervals
func (s *State) AddForkIDInterval(ctx context.Context, newForkID ForkIDInterval, dbTx pgx.Tx) error {
return s.storage.AddForkIDInterval(ctx, newForkID, dbTx)
}
// GetForkIDByBatchNumber returns the fork id for a given batch number
func (s *State) GetForkIDByBatchNumber(batchNumber uint64) uint64 {
return s.storage.GetForkIDByBatchNumber(batchNumber)
}
// GetForkIDByBlockNumber returns the fork id for a given block number
func (s *State) GetForkIDByBlockNumber(blockNumber uint64) uint64 {
return s.storage.GetForkIDByBlockNumber(blockNumber)
}