Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Sep 11, 2024
1 parent ad8ead5 commit 2cca86d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions server/v2/cometbft/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
return fmt.Errorf("failed to unmarshal config: %w", err)
}
}

s.config = Config{
ConfigTomlConfig: configTomlConfig,
AppTomlConfig: appTomlConfig,
Expand Down
15 changes: 10 additions & 5 deletions server/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ func ReadConfig(configPath string) (*viper.Viper, error) {
return v, nil
}

// UnmarshalSubConfig unmarshals the given sub config from the main config (given as a map) into the target.
// UnmarshalSubConfig unmarshals the given (sub) config from the main config (given as a map) into the target.
// If subName is empty, the main config is unmarshaled into the target.
func UnmarshalSubConfig(cfg map[string]any, subName string, target any) error {
var sub any
for k, val := range cfg {
if k == subName {
sub = val
break
if subName != "" {
for k, val := range cfg {
if k == subName {
sub = val
break
}
}
} else {
sub = cfg
}

// Create a new decoder with custom decoding options
Expand Down

0 comments on commit 2cca86d

Please sign in to comment.