forked from dymensionxyz/dymint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
49 lines (42 loc) · 1.71 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
48
49
package settlement
import (
"errors"
"time"
)
// Config for the DymensionLayerClient
type Config struct {
KeyringBackend string `mapstructure:"keyring_backend"`
NodeAddress string `mapstructure:"settlement_node_address"`
KeyringHomeDir string `mapstructure:"keyring_home_dir"`
DymAccountName string `mapstructure:"dym_account_name"`
RollappID string `mapstructure:"rollapp_id"`
GasLimit uint64 `mapstructure:"settlement_gas_limit"`
GasPrices string `mapstructure:"settlement_gas_prices"`
GasFees string `mapstructure:"settlement_gas_fees"`
RetryAttempts uint `mapstructure:"retry_attempts"`
RetryMaxDelay time.Duration `mapstructure:"retry_max_delay"`
RetryMinDelay time.Duration `mapstructure:"retry_min_delay"`
BatchAcceptanceTimeout time.Duration `mapstructure:"batch_acceptance_timeout"`
BatchAcceptanceAttempts uint `mapstructure:"batch_acceptance_attempts"`
// For testing only. probably should be refactored
ProposerPubKey string `json:"proposer_pub_key"`
// Config used for sl shared grpc mock
SLGrpc GrpcConfig `mapstructure:",squash"`
}
type GrpcConfig struct {
Host string `json:"host"`
Port int `json:"port"`
RefreshTime int `json:"refresh_time"`
}
func (c Config) Validate() error {
if c.GasPrices != "" && c.GasFees != "" {
return errors.New("cannot provide both fees and gas prices")
}
if c.GasPrices == "" && c.GasFees == "" {
return errors.New("must provide either fees or gas prices")
}
if c.RollappID == "" {
return errors.New("must provide rollapp id")
}
return nil
}