l2_client.go 1.02 KB
Newer Older
1
package common
2 3 4 5

import (
	"context"

Sabnock01's avatar
Sabnock01 committed
6
	"github.com/ethereum-optimism/optimism/op-service/client"
7
	"github.com/ethereum-optimism/optimism/op-service/eth"
Sabnock01's avatar
Sabnock01 committed
8 9
	"github.com/ethereum-optimism/optimism/op-service/sources"
	"github.com/ethereum-optimism/optimism/op-service/sources/caching"
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/log"
)

type L2Client struct {
	*sources.L2Client
}

type L2ClientConfig struct {
	*sources.L2ClientConfig
}

func NewL2Client(client client.RPC, log log.Logger, metrics caching.Metrics, config *L2ClientConfig) (*L2Client, error) {
	l2Client, err := sources.NewL2Client(client, log, metrics, config.L2ClientConfig)
	if err != nil {
		return nil, err
	}
	return &L2Client{
		L2Client: l2Client,
	}, nil
}

32 33
func (s *L2Client) OutputByRoot(ctx context.Context, blockRoot common.Hash) (eth.Output, error) {
	return s.OutputV0AtBlock(ctx, blockRoot)
34
}
35 36 37 38

func (s *L2Client) OutputByNumber(ctx context.Context, blockNum uint64) (eth.Output, error) {
	return s.OutputV0AtBlockNumber(ctx, blockNum)
}