prysm-pulse/validator/graffiti/parse_graffiti.go
terence tsao b4437e6cec
Load graffiti from file (#8041)
* Pass graffati file and   use it

* Visibility

* Parse test

* More proposal tests

* Gazelle

* Add sequential functionality

* fix length check

* Update priorities. Specified -> random -> default

* Log warn instead return err

* Comment

* E2e test

* Comment

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
2020-12-04 23:15:12 +00:00

27 lines
572 B
Go

package graffiti
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type Graffiti struct {
Default string `yaml:"default,omitempty"`
Random []string `yaml:"random,omitempty"`
Specific map[uint64]string `yaml:"specific,omitempty"`
}
// 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
}