mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
prysmctl using the same genesis func as e2e (#12268)
* prysmctl using the same genesis func as e2e * add whitespace to genesis.json for readability * fix typo in fork name * don't require validator count if deposits given * add gosec exception * the other nosec :( * appease deepsource * fix comments on renamed public value/func --------- Co-authored-by: kasey <kasey@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ go_library(
|
||||
"gitTag": "{STABLE_GIT_TAG}",
|
||||
},
|
||||
deps = [
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
||||
],
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package version
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
const (
|
||||
Phase0 = iota
|
||||
Altair
|
||||
@@ -7,22 +9,50 @@ const (
|
||||
Capella
|
||||
)
|
||||
|
||||
var versionToString = map[int]string{
|
||||
Phase0: "phase0",
|
||||
Altair: "altair",
|
||||
Bellatrix: "bellatrix",
|
||||
Capella: "capella",
|
||||
}
|
||||
|
||||
// stringToVersion and allVersions are populated in init()
|
||||
var stringToVersion = map[string]int{}
|
||||
var allVersions = []int{}
|
||||
|
||||
// ErrUnrecognizedVersionName means a string does not match the list of canonical version names.
|
||||
var ErrUnrecognizedVersionName = errors.New("version name doesn't map to a known value in the enum")
|
||||
|
||||
// FromString translates a canonical version name to the version number.
|
||||
func FromString(name string) (int, error) {
|
||||
v, ok := stringToVersion[name]
|
||||
if !ok {
|
||||
return 0, errors.Wrap(ErrUnrecognizedVersionName, name)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// String returns the canonical string form of a version.
|
||||
// Unrecognized versions won't generate an error and are represented by the string "unknown version".
|
||||
func String(version int) string {
|
||||
switch version {
|
||||
case Phase0:
|
||||
return "phase0"
|
||||
case Altair:
|
||||
return "altair"
|
||||
case Bellatrix:
|
||||
return "bellatrix"
|
||||
case Capella:
|
||||
return "capella"
|
||||
default:
|
||||
name, ok := versionToString[version]
|
||||
if !ok {
|
||||
return "unknown version"
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// All returns a list of all known fork versions.
|
||||
func All() []int {
|
||||
return []int{Phase0, Altair, Bellatrix, Capella}
|
||||
return allVersions
|
||||
}
|
||||
|
||||
func init() {
|
||||
allVersions = make([]int, len(versionToString))
|
||||
i := 0
|
||||
for v, s := range versionToString {
|
||||
allVersions[i] = v
|
||||
stringToVersion[s] = v
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user