diff --git a/general.go b/general.go index e10d674..99f55f5 100644 --- a/general.go +++ b/general.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "math/big" "net/http" "strconv" @@ -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) @@ -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() @@ -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() @@ -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 @@ -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() diff --git a/main.go b/main.go index b19d867..e4a8060 100644 --- a/main.go +++ b/main.go @@ -7,13 +7,13 @@ import ( "net/http" "os" + tmrpc "github.com/cometbft/cometbft/rpc/client/http" 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" )