diff --git a/rpc/cosmos/api.go b/rpc/cosmos/api.go index fda93fd..10e37b5 100644 --- a/rpc/cosmos/api.go +++ b/rpc/cosmos/api.go @@ -74,6 +74,8 @@ func GetStatus(rpcAddr string) (*Status, error) { return nil, fmt.Errorf("request failed %s", string(rawBody)) } + defer resp.Body.Close() + status, err := parseRawStatus(rawBody) if err != nil { return nil, err diff --git a/rpc/cosmos/health.go b/rpc/cosmos/health.go index 6d76b2a..0a97f8e 100644 --- a/rpc/cosmos/health.go +++ b/rpc/cosmos/health.go @@ -22,5 +22,8 @@ func GetHealth(rpcAddr string) (int, error) { log.Error().Str("Response", "Error").Msg(fmt.Sprintf("%v", err)) return -1, err } + + defer resp.Body.Close() + return resp.StatusCode, nil } diff --git a/rpc/cosmos/net_info.go b/rpc/cosmos/net_info.go index b23a89c..88a9764 100644 --- a/rpc/cosmos/net_info.go +++ b/rpc/cosmos/net_info.go @@ -102,6 +102,8 @@ func GetNpeers(rpcAddr string) (string, error) { return strconv.Itoa(resp.StatusCode), fmt.Errorf("request failed %s", string(rawBody)) } + defer resp.Body.Close() + info := netInfo{} err = json.Unmarshal(rawBody, &info) diff --git a/rpc/cosmos/validators.go b/rpc/cosmos/validators.go index 73640ae..abbd8b6 100644 --- a/rpc/cosmos/validators.go +++ b/rpc/cosmos/validators.go @@ -73,6 +73,8 @@ func GetBondStatus(rpcAddr string, valoperAddr string) (bool, error) { return false, fmt.Errorf("request failed %d %s", resp.StatusCode, string(rawBody)) } + defer resp.Body.Close() + status := validatorStatus{} err = json.Unmarshal(rawBody, &status)