Skip to content

Commit

Permalink
fix: not panic now
Browse files Browse the repository at this point in the history
  • Loading branch information
albttx committed Mar 7, 2024
1 parent a098421 commit a3d145e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions general.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"math/big"
"net/http"
"strconv"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)


func queryGovCount(conn *grpc.ClientConn) (int, error) {
// Handle v1beta1
govv1beta1Client := govv1beta1.NewQueryClient(conn)
Expand Down Expand Up @@ -56,8 +56,6 @@ func queryGovCount(conn *grpc.ClientConn) (int, error) {
return 0, nil
}



func (s *service) GeneralHandler(w http.ResponseWriter, r *http.Request) {
requestStart := time.Now()

Expand Down Expand Up @@ -288,6 +286,12 @@ func (s *service) GeneralHandler(w http.ResponseWriter, r *http.Request) {
wg.Add(1)
go func() {
defer wg.Done()
defer func() {
if r := recover(); r != nil {
sublogger.Error().Msg(fmt.Sprintf("Failed to query inflation: %v", r))
}
}()

sublogger.Debug().Msg("Started querying inflation")
queryStart := time.Now()

Expand All @@ -296,6 +300,7 @@ func (s *service) GeneralHandler(w http.ResponseWriter, r *http.Request) {
context.Background(),
&minttypes.QueryInflationRequest{},
)
fmt.Println("COUCOU")
if err != nil {
sublogger.Error().Err(err).Msg("Could not get inflation")
return
Expand All @@ -317,6 +322,12 @@ func (s *service) GeneralHandler(w http.ResponseWriter, r *http.Request) {
wg.Add(1)
go func() {
defer wg.Done()
defer func() {
if r := recover(); r != nil {
sublogger.Error().Msg(fmt.Sprintf("Failed to query annual provision: %v", r))
}
}()

sublogger.Debug().Msg("Started querying annual provisions")
queryStart := time.Now()

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"net/http"
"os"

tmrpc "github.com/cometbft/cometbft/rpc/client/http"

Check failure on line 10 in main.go

View workflow job for this annotation

GitHub Actions / go-vet

no required module provides package github.com/cometbft/cometbft/rpc/client/http; to add it:

Check failure on line 10 in main.go

View workflow job for this annotation

GitHub Actions / go-build

no required module provides package github.com/cometbft/cometbft/rpc/client/http; to add it:
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
tmrpc "github.com/tendermint/tendermint/rpc/client/http"
"google.golang.org/grpc"
)

Expand Down

0 comments on commit a3d145e

Please sign in to comment.