Skip to content

Commit

Permalink
set fallback 32eth when query config is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Dec 6, 2024
1 parent ada1ab0 commit 5134638
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fetcher/beaconchain/beaconchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,20 @@ func Init(confPath string) error {
u := urlEndpoint.JoinPath(urlQuerySlotsPerEpoch)
res, err := http.Get(u.String())
if err != nil {
return err
panic(feedertypes.ErrInitFail.Wrap(err.Error()))
}
result, err := io.ReadAll(res.Body)
if err != nil {
return err
panic(feedertypes.ErrInitFail.Wrap(err.Error()))
}
var re ResultConfig
if err = json.Unmarshal(result, &re); err != nil {
return err
panic(feedertypes.ErrInitFail.Wrap(err.Error()))
}

if slotsPerEpoch, err = strconv.ParseUint(re.Data.SlotsPerEpoch, 10, 64); err != nil {
return err
log.Printf("Failed to get slotsPerEpoch from beaconchain endpoint with error:%s, we use fallback value of 32ETH instead of panic", err)
slotsPerEpoch = 32
}
return nil
}
Expand Down

0 comments on commit 5134638

Please sign in to comment.