github.com/ava-labs/avalanchego@v1.11.11/genesis/validators.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 validators.json 19 validatorsPerNetworkJSON []byte 20 21 validatorsPerNetwork map[string]set.Set[ids.NodeID] 22 ) 23 24 func init() { 25 if err := json.Unmarshal(validatorsPerNetworkJSON, &validatorsPerNetwork); err != nil { 26 panic(fmt.Sprintf("failed to decode validators.json: %v", err)) 27 } 28 } 29 30 // GetValidators returns recent validators for the requested network. 31 func GetValidators(networkID uint32) set.Set[ids.NodeID] { 32 networkName := constants.NetworkIDToNetworkName[networkID] 33 return validatorsPerNetwork[networkName] 34 }