-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
47 lines (38 loc) · 1.38 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package checkexecutionsyncstatus
import (
"errors"
"time"
"github.com/ethpandaops/assertoor/pkg/coordinator/human-duration"
)
type Config struct {
ClientPattern string `yaml:"clientPattern" json:"clientPattern"`
PollInterval human.Duration `yaml:"pollInterval" json:"pollInterval"`
ExpectSyncing bool `yaml:"expectSyncing" json:"expectSyncing"`
ExpectMinPercent float64 `yaml:"expectMinPercent" json:"expectMinPercent"`
ExpectMaxPercent float64 `yaml:"expectMaxPercent" json:"expectMaxPercent"`
MinBlockHeight int `yaml:"minBlockHeight" json:"minBlockHeight"`
WaitForChainProgression bool `yaml:"waitForChainProgression" json:"waitForChainProgression"`
}
func DefaultConfig() Config {
return Config{
PollInterval: human.Duration{Duration: 5 * time.Second},
ExpectMinPercent: 100,
ExpectMaxPercent: 100,
MinBlockHeight: 10,
}
}
func (c *Config) Validate() error {
if c.ExpectMinPercent > 100 {
return errors.New("expectMinPercent must be less than 100")
}
if c.ExpectMaxPercent > 100 {
return errors.New("ExpectMaxPercent must be less than 100")
}
if c.ExpectMaxPercent < c.ExpectMinPercent {
return errors.New("ExpectMaxPercent must be <= ExpectMinPercent")
}
if c.MinBlockHeight < 0 {
return errors.New("minBlockHeight must be >= 0")
}
return nil
}