diff --git a/cmd-rpc.go b/cmd-rpc.go index 960227fb..23e8d293 100644 --- a/cmd-rpc.go +++ b/cmd-rpc.go @@ -164,34 +164,32 @@ func newCmd_rpc() *cli.Command { wg.SetLimit(epochLoadConcurrency) for confIndex := range configs { config := configs[confIndex] - { - wg.Go(func() error { - epochNum := *config.Epoch - err := func() error { - epoch, err := NewEpochFromConfig( - config, - c, - allCache, - minerInfo, - ) - if err != nil { - return fmt.Errorf("failed to create epoch from config %q: %s", config.ConfigFilepath(), err.Error()) - } - if err := multi.AddEpoch(epoch.Epoch(), epoch); err != nil { - return fmt.Errorf("failed to add epoch %d: %s", epoch.Epoch(), err.Error()) - } - return nil - }() + wg.Go(func() error { + epochNum := *config.Epoch + err := func() error { + epoch, err := NewEpochFromConfig( + config, + c, + allCache, + minerInfo, + ) if err != nil { - metrics_epochsAvailable.WithLabelValues(fmt.Sprintf("%d", epochNum)).Set(0) - klog.Error(err) - // NOTE: DO NOT return the error here, as we want to continue loading other epochs - return nil + return fmt.Errorf("failed to create epoch from config %q: %s", config.ConfigFilepath(), err.Error()) + } + if err := multi.AddEpoch(epoch.Epoch(), epoch); err != nil { + return fmt.Errorf("failed to add epoch %d: %s", epoch.Epoch(), err.Error()) } - metrics_epochsAvailable.WithLabelValues(fmt.Sprintf("%d", epochNum)).Set(1) return nil - }) - } + }() + if err != nil { + metrics_epochsAvailable.WithLabelValues(fmt.Sprintf("%d", epochNum)).Set(0) + klog.Error(err) + // NOTE: DO NOT return the error here, as we want to continue loading other epochs + return nil + } + metrics_epochsAvailable.WithLabelValues(fmt.Sprintf("%d", epochNum)).Set(1) + return nil + }) } if err := wg.Wait(); err != nil { klog.Errorf("fatal error initializing epochs: %s", err.Error())