github.com/ava-labs/avalanchego@v1.11.11/genesis/checkpoints.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package genesis 5 6 import ( 7 "encoding/json" 8 "fmt" 9 10 _ "embed" 11 12 "github.com/ava-labs/avalanchego/ids" 13 "github.com/ava-labs/avalanchego/utils/constants" 14 "github.com/ava-labs/avalanchego/utils/set" 15 ) 16 17 var ( 18 //go:embed checkpoints.json 19 checkpointsPerNetworkJSON []byte 20 21 checkpointsPerNetwork map[string]map[ids.ID]set.Set[ids.ID] 22 ) 23 24 func init() { 25 if err := json.Unmarshal(checkpointsPerNetworkJSON, &checkpointsPerNetwork); err != nil { 26 panic(fmt.Sprintf("failed to decode checkpoints.json: %v", err)) 27 } 28 } 29 30 // GetCheckpoints returns all known checkpoints for the chain on the requested 31 // network. 32 func GetCheckpoints(networkID uint32, chainID ids.ID) set.Set[ids.ID] { 33 networkName := constants.NetworkIDToNetworkName[networkID] 34 return checkpointsPerNetwork[networkName][chainID] 35 }