-
Notifications
You must be signed in to change notification settings - Fork 640
/
checkpoints.go
35 lines (27 loc) · 900 Bytes
/
checkpoints.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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package genesis
import (
"encoding/json"
"fmt"
_ "embed"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/set"
)
var (
//go:embed checkpoints.json
checkpointsPerNetworkJSON []byte
checkpointsPerNetwork map[string]map[ids.ID]set.Set[ids.ID]
)
func init() {
if err := json.Unmarshal(checkpointsPerNetworkJSON, &checkpointsPerNetwork); err != nil {
panic(fmt.Sprintf("failed to decode checkpoints.json: %v", err))
}
}
// GetCheckpoints returns all known checkpoints for the chain on the requested
// network.
func GetCheckpoints(networkID uint32, chainID ids.ID) set.Set[ids.ID] {
networkName := constants.NetworkIDToNetworkName[networkID]
return checkpointsPerNetwork[networkName][chainID]
}