Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Aug 27, 2024
1 parent e561897 commit d1f6390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 51 deletions.
16 changes: 7 additions & 9 deletions providers/apis/defi/ethmulticlient/multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.

results := make([]result, len(m.clients))

// error slice to capture errors go routines encounter.
errs := make([]error, len(m.clients))
wg := new(sync.WaitGroup)
// this is the index of where we will have an eth_blockNumber call.
blockNumReqIndex := len(batchElems)
Expand All @@ -133,8 +131,8 @@ func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.
// if there was an error, or if the block_num request didn't have result / errored
// we log the error and append to error slice.
if err != nil || req[blockNumReqIndex].Result == "" || req[blockNumReqIndex].Error != nil {
errs[i] = fmt.Errorf("endpoint request failed: %w, %w", err, req[blockNumReqIndex].Error)
results[i] = result{0, nil, errs[i]}
resultErr := fmt.Errorf("endpoint request failed: %w, %w", err, req[blockNumReqIndex].Error)
results[i] = result{0, nil, resultErr}
m.logger.Debug(
"endpoint request failed",
zap.Error(err),
Expand All @@ -148,8 +146,8 @@ func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.
// try to get the block number.
r, ok := req[blockNumReqIndex].Result.(*string)
if !ok {
errs[i] = fmt.Errorf("result from eth_blockNumber was not a string")
results[i] = result{0, nil, errs[i]}
resultErr := fmt.Errorf("result from eth_blockNumber was not a string")
results[i] = result{0, nil, resultErr}
m.logger.Debug(
"result from eth_blockNumber was not a string",
zap.String("url", url),
Expand All @@ -160,8 +158,8 @@ func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.
// decode the new height
height, err := hexutil.DecodeUint64(*r)
if err != nil { // if we can't decode the height, log an error.
errs[i] = fmt.Errorf("could not decode hex eth height: %w", err)
results[i] = result{0, nil, errs[i]}
resultErr := fmt.Errorf("could not decode hex eth height: %w", err)
results[i] = result{0, nil, resultErr}
m.logger.Debug(
"could not decode hex eth height",
zap.String("url", url),
Expand All @@ -175,7 +173,7 @@ func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.
zap.String("url", url),
)
// append the results, minus the appended eth_blockNumber request.
results[i] = result{height, req[:blockNumReqIndex], errs[i]}
results[i] = result{height, req[:blockNumReqIndex], nil}
}(clientIdx)
}
wg.Wait()
Expand Down
42 changes: 0 additions & 42 deletions providers/apis/defi/types/mocks/block_age_checker.go

This file was deleted.

0 comments on commit d1f6390

Please sign in to comment.