Documentation ¶
Index ¶
- Constants
- func NewHTTPClient(log *slog.Logger) *retryablehttp.Client
- type ArbitrumNitroClient
- func (c *ArbitrumNitroClient) BlockByNumber(ctx context.Context, blockNumber int64) (models.RPCBlock, error)
- func (c *ArbitrumNitroClient) Close() error
- func (c *ArbitrumNitroClient) GroupedJSONrpc(ctx context.Context, group *errgroup.Group, method string, args []any, ...)
- func (c *ArbitrumNitroClient) LatestBlockNumber() (int64, error)
- type BlockchainClient
- type Config
- type HTTPClient
- type OpStackClient
- func (c *OpStackClient) BlockByNumber(ctx context.Context, blockNumber int64) (models.RPCBlock, error)
- func (c *OpStackClient) Close() error
- func (c *OpStackClient) GroupedJSONrpc(ctx context.Context, group *errgroup.Group, method string, args []any, ...)
- func (c *OpStackClient) LatestBlockNumber() (int64, error)
Constants ¶
const ( MaxRetries = 10 DefaultRequestTimeout = 30 * time.Second DefaultMaxRPCConcurrency = 50 // safe default )
Variables ¶
This section is empty.
Functions ¶
func NewHTTPClient ¶
Types ¶
type ArbitrumNitroClient ¶
type ArbitrumNitroClient struct {
// contains filtered or unexported fields
}
func (*ArbitrumNitroClient) BlockByNumber ¶
func (c *ArbitrumNitroClient) BlockByNumber(ctx context.Context, blockNumber int64) (models.RPCBlock, error)
BlockByNumber returns the block with the given blockNumber. it uses 3 different methods to get the block:
- eth_getBlockByNumber
- debug_traceBlockByNumber with tracer "callTracer" TODO: this method should be optional
- call to eth_getTransactionReceipt for each Tx present in the Block
We encode the payload in NDJSON
func (*ArbitrumNitroClient) GroupedJSONrpc ¶
func (c *ArbitrumNitroClient) GroupedJSONrpc( ctx context.Context, group *errgroup.Group, method string, args []any, output *bytes.Buffer, debugBlockNumber int64, )
GroupedJSONrpc is a helper function to spawn multiple calls belonging to the same group. errors are propagated to the errgroup. concurrency is managed by the worker pool.
func (*ArbitrumNitroClient) LatestBlockNumber ¶
type BlockchainClient ¶
type BlockchainClient interface { LatestBlockNumber() (int64, error) BlockByNumber(ctx context.Context, blockNumber int64) (models.RPCBlock, error) Close() error }
func NewRPCClient ¶
func NewRPCClient(log *slog.Logger, client HTTPClient, cfg Config) (BlockchainClient, error)
type Config ¶
type Config struct { URL string PollInterval time.Duration HTTPHeaders map[string]string EVMStack models.EVMStack // rpcClient is used in parallel by the ingester to fetch blocks // but it also has internal request concurrency on handling each block // to avoid spawning too many http requests to the RPC node we set here an upper limit TotalRPCConcurrency int }
type HTTPClient ¶
type OpStackClient ¶
type OpStackClient struct {
// contains filtered or unexported fields
}
func (*OpStackClient) BlockByNumber ¶
func (c *OpStackClient) BlockByNumber(ctx context.Context, blockNumber int64) (models.RPCBlock, error)
BlockByNumber returns the block with the given blockNumber. it uses 3 different methods to get the block: 1. eth_getBlockByNumber 2. eth_getBlockReceipts 3. debug_traceBlockByNumber with tracer "callTracer" We encode the payload in NDJSON, in this order. TODO: debug_traceBlockByNumber should be optional
we should handle the case where it is not available
func (*OpStackClient) GroupedJSONrpc ¶
func (c *OpStackClient) GroupedJSONrpc( ctx context.Context, group *errgroup.Group, method string, args []any, output *bytes.Buffer, debugBlockNumber int64, )
GroupedJSONrpc is a helper function to spawn multiple calls belonging to the same group. errors are propagated to the errgroup. concurrency is managed by the worker pool.