diff --git a/client/jsonrpc/client.go b/client/jsonrpc/client.go index 7aa637f..62d05db 100644 --- a/client/jsonrpc/client.go +++ b/client/jsonrpc/client.go @@ -121,18 +121,30 @@ func (c *rpcClient) GroupedJSONrpc( args []any, output *bytes.Buffer, debugBlockNumber int64, +) { + c.execOnPoolInGroup(group, func() error { + err := c.getResponseBody(ctx, method, args, output) + if err != nil { + c.log.Error("Failed to get response for jsonRPC", + "blockNumber", debugBlockNumber, + "method", method, + "error", err, + ) + } + return err + }) +} + +func (c *rpcClient) execOnPoolInGroup( + group *errgroup.Group, + function func() error, ) { group.Go(func() error { errCh := make(chan error, 1) c.wrkPool.Submit(func() { defer close(errCh) - err := c.getResponseBody(ctx, method, args, output) + err := function() if err != nil { - c.log.Error("Failed to get response for jsonRPC", - "blockNumber", debugBlockNumber, - "method", method, - "error", err, - ) errCh <- err } else { errCh <- nil