Skip to content

Commit 7c0492a

Browse files
committed
use context deadline for timeout in eth_call
1 parent 1552c61 commit 7c0492a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/ethapi/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,12 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
879879
if overrides != nil {
880880
accounts = *overrides
881881
}
882-
result, _, _, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, 5*time.Second, s.b.RPCGasCap())
882+
timeout := 5 * time.Second
883+
d, ok := ctx.Deadline()
884+
if ok {
885+
timeout = d.Sub(time.Now())
886+
}
887+
result, _, _, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, timeout, s.b.RPCGasCap())
883888
return (hexutil.Bytes)(result), err
884889
}
885890

0 commit comments

Comments
 (0)