From 9a4dee04f90e521832efef5febeebb1231e22a19 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 3 Aug 2023 17:24:48 +0800 Subject: [PATCH] feat(pkg): add default timeout for `GetStorageRoot` (#347) --- pkg/rpc/methods.go | 11 ++++++++++- version/version.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 44f3ed002..313b7dbc4 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -335,8 +335,17 @@ func (c *Client) GetStorageRoot( contract common.Address, height *big.Int, ) (common.Hash, error) { + var ( + ctxWithTimeout = ctx + cancel context.CancelFunc + ) + if _, ok := ctx.Deadline(); !ok { + ctxWithTimeout, cancel = context.WithTimeout(ctx, defaultTimeout) + defer cancel() + } + proof, err := gethclient.GetProof( - ctx, + ctxWithTimeout, contract, []string{"0x0000000000000000000000000000000000000000000000000000000000000000"}, height, diff --git a/version/version.go b/version/version.go index 7140be7ee..e2bf17534 100644 --- a/version/version.go +++ b/version/version.go @@ -2,7 +2,7 @@ package version // Version info. var ( - Version = "0.13.0" + Version = "0.14.0" Meta = "dev" )