From c8190e549cf374c4c6a905a7bb52169b63710743 Mon Sep 17 00:00:00 2001 From: reneecok Date: Tue, 20 Jun 2023 20:52:06 +0800 Subject: [PATCH] feat: allows for setting a custom http client when NewClientFromNode --- client/utils.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/utils.go b/client/utils.go index affd0211cb..f89f22a29e 100644 --- a/client/utils.go +++ b/client/utils.go @@ -2,6 +2,7 @@ package client import ( "encoding/base64" + "net/http" rpchttp "github.com/cometbft/cometbft/rpc/client/http" "github.com/spf13/pflag" @@ -84,6 +85,13 @@ func NewClientFromNode(nodeURI string) (*rpchttp.HTTP, error) { return rpchttp.New(nodeURI, "/websocket") } +// NewClientFromNodeWithClient allows for setting a custom http client +// sets up Client implementation that communicates with a Tendermint node over +// JSON RPC and WebSockets +func NewClientFromNodeWithClient(nodeURI string, client *http.Client) (*rpchttp.HTTP, error) { + return rpchttp.NewWithClient(nodeURI, "/websocket", client) +} + // FlagSetWithPageKeyDecoded returns the provided flagSet with the page-key value base64 decoded (if it exists). // This is for when the page-key is provided as a base64 string (e.g. from the CLI). // ReadPageRequest expects it to be the raw bytes.