2020-12-04 23:15:12 +00:00
|
|
|
package graffiti
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
2021-02-23 00:14:50 +00:00
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
2020-12-04 23:15:12 +00:00
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Graffiti struct {
|
2021-02-23 00:14:50 +00:00
|
|
|
Default string `yaml:"default,omitempty"`
|
|
|
|
Random []string `yaml:"random,omitempty"`
|
|
|
|
Specific map[types.ValidatorIndex]string `yaml:"specific,omitempty"`
|
2020-12-04 23:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ParseGraffitiFile parses the graffiti file and returns the graffiti struct.
|
|
|
|
func ParseGraffitiFile(f string) (*Graffiti, error) {
|
|
|
|
yamlFile, err := ioutil.ReadFile(f)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
g := &Graffiti{}
|
|
|
|
if err := yaml.Unmarshal(yamlFile, g); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return g, nil
|
|
|
|
}
|