diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index 4dfb4e720a18..26cd99ff97cd 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -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, diff --git a/server/v2/config.go b/server/v2/config.go index c7df142c3805..0670bc374a24 100644 --- a/server/v2/config.go +++ b/server/v2/config.go @@ -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