Skip to content

Commit

Permalink
use context deadline for timeout in eth_call
Browse files Browse the repository at this point in the history
  • Loading branch information
i-norden committed Oct 12, 2020
1 parent 1552c61 commit 7c0492a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,12 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
if overrides != nil {
accounts = *overrides
}
result, _, _, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, 5*time.Second, s.b.RPCGasCap())
timeout := 5 * time.Second
d, ok := ctx.Deadline()
if ok {
timeout = d.Sub(time.Now())
}
result, _, _, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, timeout, s.b.RPCGasCap())
return (hexutil.Bytes)(result), err
}

Expand Down

0 comments on commit 7c0492a

Please sign in to comment.