Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion etherclient/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package etherclient

import (
"context"
"net/url"
"time"

"github.com/cenkalti/backoff"
Expand Down Expand Up @@ -48,9 +49,22 @@ func (ec *etherClient) withBackoff(
if ctx.Err() != nil {
return backoff.Permanent(ctx.Err())
}

wrapper := ec.provider.Provide()
ethClient := wrapper.Client
tCtx, cancel := context.WithTimeout(ctx, backoffContextTimeout)
err := operation(tCtx, ec.provider.Provide())
err := operation(tCtx, ethClient)
cancel()

// If metrics handler is set, call with the RPC URL and the client method that was used.
if ec.metricsHandler != nil {
rpcUrl := wrapper.url
u, err := url.Parse(rpcUrl)
if err == nil {
ec.metricsHandler(u.Host, method)
}
}

if err != nil {
// Move onto the next provider.
ec.provider.Next()
Expand Down
Loading
Loading