mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
f0eb843138
* Added ordered option to graffiti file * Updated validator to use Ordered graffiti * Track graffiti ordered index in db * Update `ordered` to only emit each graffiti once Co-authored-by: pinglamb <pinglambs@gmail.com>
32 lines
831 B
Go
32 lines
831 B
Go
package graffiti
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Graffiti struct {
|
|
Hash [32]byte
|
|
Default string `yaml:"default,omitempty"`
|
|
Ordered []string `yaml:"ordered,omitempty"`
|
|
Random []string `yaml:"random,omitempty"`
|
|
Specific map[types.ValidatorIndex]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
|
|
}
|
|
g.Hash = hashutil.Hash(yamlFile)
|
|
return g, nil
|
|
}
|