Skip to content

Commit 2cca86d

Browse files
committed
updates
1 parent ad8ead5 commit 2cca86d

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

server/v2/cometbft/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
7272
return fmt.Errorf("failed to unmarshal config: %w", err)
7373
}
7474
}
75+
7576
s.config = Config{
7677
ConfigTomlConfig: configTomlConfig,
7778
AppTomlConfig: appTomlConfig,

server/v2/config.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ func ReadConfig(configPath string) (*viper.Viper, error) {
3939
return v, nil
4040
}
4141

42-
// UnmarshalSubConfig unmarshals the given sub config from the main config (given as a map) into the target.
42+
// UnmarshalSubConfig unmarshals the given (sub) config from the main config (given as a map) into the target.
43+
// If subName is empty, the main config is unmarshaled into the target.
4344
func UnmarshalSubConfig(cfg map[string]any, subName string, target any) error {
4445
var sub any
45-
for k, val := range cfg {
46-
if k == subName {
47-
sub = val
48-
break
46+
if subName != "" {
47+
for k, val := range cfg {
48+
if k == subName {
49+
sub = val
50+
break
51+
}
4952
}
53+
} else {
54+
sub = cfg
5055
}
5156

5257
// Create a new decoder with custom decoding options

0 commit comments

Comments
 (0)