Documentation
¶
Index ¶
- Variables
- type ChainProviderImpl
- func (c *ChainProviderImpl) BalanceAt(ctx context.Context, address common.Address, blockNumber *big.Int) (*big.Int, error)
- func (c *ChainProviderImpl) BlockByNumber(ctx context.Context, num *big.Int) (*types.Block, error)
- func (c *ChainProviderImpl) BlockNumber(ctx context.Context) (uint64, error)
- func (c *ChainProviderImpl) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error)
- func (c *ChainProviderImpl) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (c *ChainProviderImpl) ChainID(ctx context.Context) (*big.Int, error)
- func (c *ChainProviderImpl) ClientID() string
- func (c *ChainProviderImpl) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (c *ChainProviderImpl) EnableMetrics(m telemetry.Metrics)
- func (c *ChainProviderImpl) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
- func (c *ChainProviderImpl) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (c *ChainProviderImpl) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (c *ChainProviderImpl) Health() bool
- func (c *ChainProviderImpl) NonceAt(ctx context.Context, account common.Address, bn *big.Int) (uint64, error)
- func (c *ChainProviderImpl) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (c *ChainProviderImpl) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (c *ChainProviderImpl) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (c *ChainProviderImpl) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (c *ChainProviderImpl) SubscribeNewHead(ctx context.Context) (chan *types.Header, ethereum.Subscription, error)
- func (c *ChainProviderImpl) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (c *ChainProviderImpl) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (c *ChainProviderImpl) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)
- func (c *ChainProviderImpl) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (c *ChainProviderImpl) TxPoolContentFrom(ctx context.Context, address common.Address) (map[string]map[uint64]*types.Transaction, error)
- func (c *ChainProviderImpl) TxPoolInspect(ctx context.Context) (map[string]map[common.Address]map[uint64]string, error)
- type Client
- type ConnectionPool
- type ConnectionPoolConfig
- type ConnectionPoolImpl
- func (c *ConnectionPoolImpl) Close() error
- func (c *ConnectionPoolImpl) Dial(string) error
- func (c *ConnectionPoolImpl) DialContext(ctx context.Context, _ string) error
- func (c *ConnectionPoolImpl) GetHTTP() (Client, bool)
- func (c *ConnectionPoolImpl) GetWS() (Client, bool)
- func (c *ConnectionPoolImpl) RemoveChainClient(clientAddr string) error
- type ExtendedEthClient
- func (c *ExtendedEthClient) ClientID() string
- func (c *ExtendedEthClient) Close() error
- func (c *ExtendedEthClient) DialContext(ctx context.Context, rawurl string) error
- func (c *ExtendedEthClient) GetReceipts(ctx context.Context, txs ethcoretypes.Transactions) (ethcoretypes.Receipts, error)
- func (c *ExtendedEthClient) Health() bool
- func (c *ExtendedEthClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethcoretypes.Log) (ethereum.Subscription, error)
- func (c *ExtendedEthClient) SubscribeNewHead(ctx context.Context) (chan *ethcoretypes.Header, ethereum.Subscription, error)
- func (c *ExtendedEthClient) TxPoolContentFrom(ctx context.Context, address common.Address) (map[string]map[uint64]*ethcoretypes.Transaction, error)
- func (c *ExtendedEthClient) TxPoolInspect(ctx context.Context) (map[string]map[common.Address]map[uint64]string, error)
- type HealthCheckedClient
- func (c *HealthCheckedClient) ClientID() string
- func (c *HealthCheckedClient) DialContextWithTimeout(ctx context.Context, rawurl string, rpcTimeout time.Duration) error
- func (c *HealthCheckedClient) Health() bool
- func (c *HealthCheckedClient) SetHealthy(healthy bool)
- func (c *HealthCheckedClient) StartHealthCheck(ctx context.Context)
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyDial = errors.New("client is already dialed, please Close() before dialing again") ErrClosed = errors.New("client is already closed, please Dial() before closing again") )
var (
ErrClientNotFound = errors.New("client not found")
)
ErrClientNotFound is an error that is returned when a client is not found.
Functions ¶
This section is empty.
Types ¶
type ChainProviderImpl ¶
type ChainProviderImpl struct {
ConnectionPool
// contains filtered or unexported fields
}
ChainProviderImpl is an implementation of the ChainProvider interface.
func (*ChainProviderImpl) BalanceAt ¶
func (c *ChainProviderImpl) BalanceAt( ctx context.Context, address common.Address, blockNumber *big.Int) (*big.Int, error)
BalanceAt returns the balance of the given address at the given block number.
func (*ChainProviderImpl) BlockByNumber ¶
BlockByNumber returns the block for the given number.
func (*ChainProviderImpl) BlockNumber ¶
func (c *ChainProviderImpl) BlockNumber(ctx context.Context) (uint64, error)
BlockNumber returns the current block number.
func (*ChainProviderImpl) BlockReceipts ¶
func (c *ChainProviderImpl) BlockReceipts( ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error)
BlockReceipts returns the receipts for the given block number or hash.
func (*ChainProviderImpl) CallContract ¶
func (c *ChainProviderImpl) CallContract( ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, ) ([]byte, error)
CallContract calls a contract with the given message at the given block number.
func (*ChainProviderImpl) ClientID ¶
func (c *ChainProviderImpl) ClientID() string
func (*ChainProviderImpl) CodeAt ¶
func (c *ChainProviderImpl) CodeAt( ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt returns the code of the given account at the given block number.
func (*ChainProviderImpl) EnableMetrics ¶
func (c *ChainProviderImpl) EnableMetrics(m telemetry.Metrics)
func (*ChainProviderImpl) EstimateGas ¶
EstimateGas estimates the gas needed to execute a specific transaction.
func (*ChainProviderImpl) FilterLogs ¶
func (c *ChainProviderImpl) FilterLogs( ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs returns the logs that satisfy the given filter query.
func (*ChainProviderImpl) HeaderByNumber ¶
func (c *ChainProviderImpl) HeaderByNumber( ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByNumber returns the header of the block with the given number.
func (*ChainProviderImpl) Health ¶
func (c *ChainProviderImpl) Health() bool
func (*ChainProviderImpl) NonceAt ¶
func (c *ChainProviderImpl) NonceAt( ctx context.Context, account common.Address, bn *big.Int) (uint64, error)
PendingNonceAt returns the nonce of the given account in the pending state.
func (*ChainProviderImpl) PendingCodeAt ¶
func (c *ChainProviderImpl) PendingCodeAt( ctx context.Context, account common.Address) ([]byte, error)
PendingCodeAt returns the code of the given account in the pending state.
func (*ChainProviderImpl) PendingNonceAt ¶
func (c *ChainProviderImpl) PendingNonceAt( ctx context.Context, account common.Address) (uint64, error)
PendingNonceAt returns the nonce of the given account in the pending state.
func (*ChainProviderImpl) SendTransaction ¶
func (c *ChainProviderImpl) SendTransaction( ctx context.Context, tx *types.Transaction) error
SendTransaction sends the given transaction.
func (*ChainProviderImpl) SubscribeFilterLogs ¶
func (c *ChainProviderImpl) SubscribeFilterLogs( ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log, ) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to new log events that satisfy the given filter query.
func (*ChainProviderImpl) SubscribeNewHead ¶
func (c *ChainProviderImpl) SubscribeNewHead( ctx context.Context) (chan *types.Header, ethereum.Subscription, error)
SubscribeNewHead subscribes to new head events.
func (*ChainProviderImpl) SuggestGasPrice ¶
SuggestGasPrice suggests a gas price.
func (*ChainProviderImpl) SuggestGasTipCap ¶
SuggestGasTipCap suggests a gas tip cap.
func (*ChainProviderImpl) TransactionByHash ¶
func (c *ChainProviderImpl) TransactionByHash( ctx context.Context, hash common.Hash, ) (*types.Transaction, bool, error)
TransactionByHash returns the transaction with the given hash.
func (*ChainProviderImpl) TransactionReceipt ¶
func (c *ChainProviderImpl) TransactionReceipt( ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt returns the receipt for the given transaction hash.
func (*ChainProviderImpl) TxPoolContentFrom ¶
func (c *ChainProviderImpl) TxPoolContentFrom(ctx context.Context, address common.Address) ( map[string]map[uint64]*types.Transaction, error, )
TxPoolContentFrom returns the pending and queued transactions of this address. Example response:
{
"pending": {
1: {
// transaction details...
},
...
},
"queued": {
3: {
// transaction details...
},
...
}
}
func (*ChainProviderImpl) TxPoolInspect ¶
func (c *ChainProviderImpl) TxPoolInspect(ctx context.Context) ( map[string]map[common.Address]map[uint64]string, error, )
TxPoolInspect returns the textual summary of all pending and queued transactions. Example response:
{
"pending": {
"0x12345": {
1: "0x12345789: 1 wei + 2 gas x 3 wei"
},
...
},
"queued": {
"0x67890": {
2: "0x12345789: 1 wei + 2 gas x 3 wei"
},
...
}
}
type Client ¶
type Client interface {
DialContext(ctx context.Context, rawurl string) error
Close() error
Health() bool
ClientID() string
Reader
Writer
}
func NewChainProviderImpl ¶
func NewChainProviderImpl(pool ConnectionPool, cfg ConnectionPoolConfig) Client
NewChainProviderImpl creates a new ChainProviderImpl with the given ConnectionPool.
type ConnectionPool ¶
type ConnectionPool interface {
GetHTTP() (Client, bool)
GetWS() (Client, bool)
RemoveChainClient(string) error
Close() error
Dial(string) error
DialContext(context.Context, string) error
}
func NewConnectionPoolImpl ¶
func NewConnectionPoolImpl(cfg ConnectionPoolConfig, logger log.Logger) (ConnectionPool, error)
type ConnectionPoolConfig ¶
type ConnectionPoolConfig struct {
EthHTTPURLs []string
EthWSURLs []string
DefaultTimeout time.Duration
HealthCheckInterval time.Duration
}
func DefaultConnectPoolConfig ¶
func DefaultConnectPoolConfig() *ConnectionPoolConfig
type ConnectionPoolImpl ¶
type ConnectionPoolImpl struct {
// contains filtered or unexported fields
}
func (*ConnectionPoolImpl) Close ¶
func (c *ConnectionPoolImpl) Close() error
func (*ConnectionPoolImpl) Dial ¶
func (c *ConnectionPoolImpl) Dial(string) error
func (*ConnectionPoolImpl) DialContext ¶
func (c *ConnectionPoolImpl) DialContext(ctx context.Context, _ string) error
func (*ConnectionPoolImpl) GetHTTP ¶
func (c *ConnectionPoolImpl) GetHTTP() (Client, bool)
NOTE: this function assumes the cache is non-nil because it is guaranteed to be non-nil when a ConnectionPoolImpl is created.
func (*ConnectionPoolImpl) GetWS ¶
func (c *ConnectionPoolImpl) GetWS() (Client, bool)
func (*ConnectionPoolImpl) RemoveChainClient ¶
func (c *ConnectionPoolImpl) RemoveChainClient(clientAddr string) error
type ExtendedEthClient ¶
client is the indexer eth client.
func NewExtendedEthClient ¶
func NewExtendedEthClient(c *ethclient.Client, rpcTimeout time.Duration) *ExtendedEthClient
func (*ExtendedEthClient) ClientID ¶
func (c *ExtendedEthClient) ClientID() string
func (*ExtendedEthClient) Close ¶
func (c *ExtendedEthClient) Close() error
Close closes the client.
func (*ExtendedEthClient) DialContext ¶
func (c *ExtendedEthClient) DialContext(ctx context.Context, rawurl string) error
func (*ExtendedEthClient) GetReceipts ¶
func (c *ExtendedEthClient) GetReceipts( ctx context.Context, txs ethcoretypes.Transactions) (ethcoretypes.Receipts, error)
GetReceipts returns the receipts for the given transactions.
func (*ExtendedEthClient) Health ¶
func (c *ExtendedEthClient) Health() bool
func (*ExtendedEthClient) SubscribeFilterLogs ¶
func (c *ExtendedEthClient) SubscribeFilterLogs( ctx context.Context, q ethereum.FilterQuery, ch chan<- ethcoretypes.Log) (ethereum.Subscription, error)
func (*ExtendedEthClient) SubscribeNewHead ¶
func (c *ExtendedEthClient) SubscribeNewHead( ctx context.Context) (chan *ethcoretypes.Header, ethereum.Subscription, error)
SubscribeNewHead subscribes to new block headers.
func (*ExtendedEthClient) TxPoolContentFrom ¶
func (c *ExtendedEthClient) TxPoolContentFrom( ctx context.Context, address common.Address, ) (map[string]map[uint64]*ethcoretypes.Transaction, error)
type HealthCheckedClient ¶
type HealthCheckedClient struct {
*ExtendedEthClient
// contains filtered or unexported fields
}
func NewHealthCheckedClient ¶
func NewHealthCheckedClient( healthCheckInterval time.Duration, logger log.Logger, ) *HealthCheckedClient
func (*HealthCheckedClient) ClientID ¶
func (c *HealthCheckedClient) ClientID() string
func (*HealthCheckedClient) DialContextWithTimeout ¶
func (*HealthCheckedClient) Health ¶
func (c *HealthCheckedClient) Health() bool
func (*HealthCheckedClient) SetHealthy ¶
func (c *HealthCheckedClient) SetHealthy(healthy bool)
func (*HealthCheckedClient) StartHealthCheck ¶
func (c *HealthCheckedClient) StartHealthCheck(ctx context.Context)
type Reader ¶
type Reader interface {
BlockByNumber(ctx context.Context, number *big.Int) (*ethcoretypes.Block, error)
BlockReceipts(
ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash,
) ([]*ethcoretypes.Receipt, error)
TransactionReceipt(ctx context.Context, txHash common.Hash) (*ethcoretypes.Receipt, error)
SubscribeNewHead(ctx context.Context) (chan *ethcoretypes.Header, ethereum.Subscription, error)
BlockNumber(ctx context.Context) (uint64, error)
ChainID(ctx context.Context) (*big.Int, error)
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethcoretypes.Log, error)
HeaderByNumber(ctx context.Context, number *big.Int) (*ethcoretypes.Header, error)
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery,
ch chan<- ethcoretypes.Log) (ethereum.Subscription, error)
SuggestGasPrice(ctx context.Context) (*big.Int, error)
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
TransactionByHash(ctx context.Context, hash common.Hash,
) (tx *ethcoretypes.Transaction, isPending bool, err error)
/*
TxPoolContentFrom returns the pending and queued transactions of this address.
Example response:
{
"pending": {
1: {
// transaction details...
},
...
},
"queued": {
3: {
// transaction details...
},
...
}
}
*/
TxPoolContentFrom(ctx context.Context, address common.Address) (
map[string]map[uint64]*ethcoretypes.Transaction, error,
)
/*
TxPoolInspect returns the textual summary of all pending and queued transactions.
Example response:
{
"pending": {
"0x12345": {
1: "0x12345789: 1 wei + 2 gas x 3 wei"
},
...
},
"queued": {
"0x67890": {
2: "0x12345789: 1 wei + 2 gas x 3 wei"
},
...
}
}
*/
TxPoolInspect(ctx context.Context) (map[string]map[common.Address]map[uint64]string, error)
}
Reader is the eth reader interface.
type Writer ¶
type Writer interface {
SendTransaction(ctx context.Context, tx *ethcoretypes.Transaction) error
}