Skip to content

Commit

Permalink
refactor: rename NewInstrumentedClient in client.go
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoieh committed Feb 9, 2024
1 parent bdd43ef commit 25c7805
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
4 changes: 2 additions & 2 deletions op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ func (bs *BatcherService) initRPCClients(ctx context.Context, cfg *CLIConfig) er
if err != nil {
return fmt.Errorf("failed to dial L1 RPC: %w", err)
}
bs.L1Client = client.NewInstrumentedClientWithClient(l1Client, bs.Metrics)
bs.L1Client = client.NewInstrumentedClient(l1Client, bs.Metrics)

l2Client, err := dial.DialEthClientWithTimeout(ctx, dial.DefaultDialTimeout, bs.Log, cfg.L2EthRpc)
if err != nil {
return fmt.Errorf("failed to dial L2 engine RPC: %w", err)
}
bs.L2Client = client.NewInstrumentedClientWithClient(l2Client, bs.Metrics)
bs.L2Client = client.NewInstrumentedClient(l2Client, bs.Metrics)

rollupClient, err := dial.DialRollupClientWithTimeout(ctx, dial.DefaultDialTimeout, bs.Log, cfg.RollupRpc)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion op-proposer/proposer/l2_output_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func NewL2OutputSubmitterConfigFromCLIConfig(cfg CLIConfig, l log.Logger, m metr
if err != nil {
return nil, err
}
l1Client = client.NewInstrumentedClientWithClient(l1Client, m)
l1Client = client.NewInstrumentedClient(l1Client, m)

rollupClient, err := dial.DialRollupClientWithTimeout(context.Background(), dial.DefaultDialTimeout, l, cfg.RollupRpc)
if err != nil {
Expand Down
15 changes: 1 addition & 14 deletions op-service/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import (
"context"
"math/big"

"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
)

type Client interface {
Expand Down Expand Up @@ -60,17 +57,7 @@ type Metricer interface {
RecordRPCClientRequest(method string) func(err error)
}

// NewInstrumentedClient creates a new instrumented client. It takes
// a concrete *rpc.Client to prevent people from passing in an already
// instrumented client.
func NewInstrumentedClient(c *rpc.Client, m *metrics.Metrics) *InstrumentedClient {
return &InstrumentedClient{
c: ethclient.NewClient(c),
m: m,
}
}

func NewInstrumentedClientWithClient(c Client, m Metricer) *InstrumentedClient {
func NewInstrumentedClient(c Client, m Metricer) *InstrumentedClient {
return &InstrumentedClient{
c: c,
m: m,
Expand Down
2 changes: 1 addition & 1 deletion op-service/txmgr/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func NewConfig(cfg CLIConfig, l log.Logger, m txmetrics.TxMetricer) (Config, err
if err != nil {
return Config{}, fmt.Errorf("could not dial eth client: %w", err)
}
l1 = client.NewInstrumentedClientWithClient(l1, m)
l1 = client.NewInstrumentedClient(l1, m)

ctx, cancel = context.WithTimeout(context.Background(), cfg.NetworkTimeout)
defer cancel()
Expand Down

0 comments on commit 25c7805

Please sign in to comment.