ipld-eth-server/pkg/geth/client/client.go
Rob Mulholand 63434f6bc9 Add tests for pkg/geth/blockchain
- inject dependencies instead of initializing them in the constructor
2018-07-18 16:34:13 -05:00

34 lines
933 B
Go

package client
import (
"context"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"math/big"
)
type Client struct {
client *ethclient.Client
}
func NewClient(client *ethclient.Client) Client {
return Client{client: client}
}
func (client Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
return client.client.BlockByNumber(ctx, number)
}
func (client Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
return client.client.CallContract(ctx, msg, blockNumber)
}
func (client Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
return client.client.FilterLogs(ctx, q)
}
func (client Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
return client.client.HeaderByNumber(ctx, number)
}