Skip to content

Commit

Permalink
nil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Dec 27, 2024
1 parent e578ca9 commit a042619
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
oracletypes "github.com/ExocoreNetwork/exocore/x/oracle/types"
fetchertypes "github.com/ExocoreNetwork/price-feeder/fetcher/types"
feedertypes "github.com/ExocoreNetwork/price-feeder/types"
types "github.com/ExocoreNetwork/price-feeder/types"

sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)
Expand Down Expand Up @@ -113,6 +112,14 @@ type FeederInfo struct {
}

func (f *feeder) Info() FeederInfo {
var lastPrice localPrice
var lastSent signInfo
if f.lastPrice != nil {
lastPrice = *f.lastPrice
}
if f.lastSent != nil {
lastSent = *f.lastSent
}
return FeederInfo{
Source: f.source,
Token: f.token,
Expand All @@ -122,8 +129,8 @@ func (f *feeder) Info() FeederInfo {
StartBaseBlock: f.startBaseBlock,
Interval: f.interval,
EndBlock: f.endBlock,
LastPrice: *f.lastPrice,
LastSent: *f.lastSent,
LastPrice: lastPrice,
LastSent: lastSent,
}
}

Expand Down Expand Up @@ -445,9 +452,13 @@ func (fs *Feeders) UpdatePrice(txHeight int64, prices []*finalPrice) {
// UpdateOracleParams updates all feeders' params from oracle params
// if the receiving channel is full, blocking until all updateParams are received by the channel
func (fs *Feeders) UpdateOracleParams(p *oracletypes.Params) {
if p == nil {
fs.logger.Error("received nil oracle params")
return
}
if len(p.TokenFeeders) == 0 {
fs.logger.Error("received empty token feeders")
return
}
fs.updateParams <- p
}

func getLogger() types.LoggerInf {
return types.GetLogger("")
}

0 comments on commit a042619

Please sign in to comment.