Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Apr 22, 2024
1 parent d795023 commit 3272c65
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions cmd-rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 3272c65

Please sign in to comment.