From a11a8df34513f817b4d0c4db1f23df77fcb919fc Mon Sep 17 00:00:00 2001 From: Srinivas Baride Date: Thu, 2 Mar 2023 09:19:53 +0530 Subject: [PATCH] Using ClientWithTimeout instead Client --- lite/query.go | 12 ++++++------ lite/tx.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lite/query.go b/lite/query.go index a75dff8..613f16a 100644 --- a/lite/query.go +++ b/lite/query.go @@ -19,7 +19,7 @@ import ( func (c *Client) queryAccount(remote string, accAddr sdk.AccAddress) (authtypes.AccountI, error) { c.log.Debug("Querying the account", "remote", remote, "address", accAddr) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -65,7 +65,7 @@ func (c *Client) QueryAccount(accAddr sdk.AccAddress) (result authtypes.AccountI func (c *Client) queryNode(remote string, nodeAddr hubtypes.NodeAddress) (*nodetypes.Node, error) { c.log.Debug("Querying the node", "remote", remote, "address", nodeAddr) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -104,7 +104,7 @@ func (c *Client) QueryNode(nodeAddr hubtypes.NodeAddress) (result *nodetypes.Nod func (c *Client) querySubscription(remote string, id uint64) (*subscriptiontypes.Subscription, error) { c.log.Debug("Querying the subscription", "remote", remote, "id", id) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -143,7 +143,7 @@ func (c *Client) QuerySubscription(id uint64) (result *subscriptiontypes.Subscri func (c *Client) queryQuota(remote string, id uint64, accAddr sdk.AccAddress) (*subscriptiontypes.Quota, error) { c.log.Debug("Querying the quota", "remote", remote, "id", id, "address", accAddr) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -182,7 +182,7 @@ func (c *Client) QueryQuota(id uint64, accAddr sdk.AccAddress) (result *subscrip func (c *Client) querySession(remote string, id uint64) (*sessiontypes.Session, error) { c.log.Debug("Querying the session", "id", id) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -219,7 +219,7 @@ func (c *Client) QuerySession(id uint64) (result *sessiontypes.Session, err erro } func (c *Client) hasNodeForPlan(remote string, id uint64, nodeAddr hubtypes.NodeAddress) (bool, error) { - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return false, err } diff --git a/lite/tx.go b/lite/tx.go index 274ba4c..cc75ed5 100644 --- a/lite/tx.go +++ b/lite/tx.go @@ -13,7 +13,7 @@ import ( func (c *Client) broadcastTx(remote string, txBytes []byte) (*sdk.TxResponse, error) { c.log.Debug("Broadcasting the transaction", "remote", remote, "size", len(txBytes)) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return nil, err } @@ -58,7 +58,7 @@ func (c *Client) BroadcastTx(txBytes []byte) (res *sdk.TxResponse, err error) { func (c *Client) calculateGas(remote string, txf tx.Factory, messages ...sdk.Msg) (uint64, error) { c.log.Debug("Calculating the gas", "remote", remote, "messages", len(messages)) - client, err := rpchttp.New(remote, "/websocket") + client, err := rpchttp.NewWithTimeout(remote, "/websocket", 5) if err != nil { return 0, err }