Skip to content

Commit

Permalink
fix: error if config does not have IBC RPC information
Browse files Browse the repository at this point in the history
  • Loading branch information
jlehtimaki committed Oct 27, 2023
1 parent fac6c90 commit b6da3ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rpc:
url: https://noble-rpc.polkachu.com:443
- chainName: nois
chainId: nois-1
url: https://rpc.cosmos.directory/nois:443
url: https://nois.rpc.kjnodes.com:443
- chainName: osmosistestnet
chainId: osmo-test-5
url: https://rpc.osmotest5.osmosis.zone:443
Expand Down
28 changes: 14 additions & 14 deletions pkg/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ func (cc IBCCollector) Collect(ch chan<- prometheus.Metric) {
log.Error(err.Error())
}

ch <- prometheus.MustNewConstMetric(
clientExpiry,
prometheus.GaugeValue,
float64(ci.ChainAClientExpiration.Unix()),
[]string{(*cc.RPCs)[path.Chain1.ChainName].ChainID, path.Chain1.ClientID, (*cc.RPCs)[path.Chain2.ChainName].ChainID, status}...,
)

ch <- prometheus.MustNewConstMetric(
clientExpiry,
prometheus.GaugeValue,
float64(ci.ChainBClientExpiration.Unix()),
[]string{(*cc.RPCs)[path.Chain2.ChainName].ChainID, path.Chain2.ClientID, (*cc.RPCs)[path.Chain1.ChainName].ChainID, status}...,
)

stuckPackets, err := ibc.GetChannelInfo(path, cc.RPCs)
if err != nil {
status = errorStatus
Expand Down Expand Up @@ -155,20 +169,6 @@ func (cc IBCCollector) Collect(ch chan<- prometheus.Metric) {
}...,
)
}

ch <- prometheus.MustNewConstMetric(
clientExpiry,
prometheus.GaugeValue,
float64(ci.ChainAClientExpiration.Unix()),
[]string{(*cc.RPCs)[path.Chain1.ChainName].ChainID, path.Chain1.ClientID, (*cc.RPCs)[path.Chain2.ChainName].ChainID, status}...,
)

ch <- prometheus.MustNewConstMetric(
clientExpiry,
prometheus.GaugeValue,
float64(ci.ChainBClientExpiration.Unix()),
[]string{(*cc.RPCs)[path.Chain2.ChainName].ChainID, path.Chain2.ClientID, (*cc.RPCs)[path.Chain1.ChainName].ChainID, status}...,
)
}(p)
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/ibc/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func GetChannelInfo(ibc *relayer.IBCdata, rpcs *map[string]config.RPC) (Channels
ctx := context.Background()
channelInfo := ChannelsInfo{}

if (*rpcs)[ibc.Chain1.ChainName].ChainID == "" || (*rpcs)[ibc.Chain2.ChainName].ChainID == "" {
return ChannelsInfo{}, fmt.Errorf(
"Error: RPC data is missing, cannot retrieve channel data",
)
}

cdA := chain.Info{
ChainID: (*rpcs)[ibc.Chain1.ChainName].ChainID,
RPCAddr: (*rpcs)[ibc.Chain1.ChainName].URL,
Expand Down

0 comments on commit b6da3ef

Please sign in to comment.