api

package
v0.71.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the node responds with HTTP 404 for the requested resource, e.g. an execution payload envelope that has not been revealed or a block that does not exist.

Functions

This section is empty.

Types

type ConsensusClient

type ConsensusClient interface {
	NodePeer(ctx context.Context, peerID string) (types.Peer, error)
	NodePeers(ctx context.Context) (types.Peers, error)
	NodePeerCount(ctx context.Context) (types.PeerCount, error)
	RawBlock(ctx context.Context, blockID string, contentType string) ([]byte, error)
	RawExecutionPayloadEnvelope(ctx context.Context, blockID string, contentType string) ([]byte, error)
	RawDebugBeaconState(ctx context.Context, stateID string, contentType string) ([]byte, error)
	// OpenRawBlock opens a successful raw block response without consuming its body.
	OpenRawBlock(ctx context.Context, blockID string, contentType string) (*RawResponse, error)
	// OpenRawExecutionPayloadEnvelope opens a successful raw envelope response without consuming its body.
	OpenRawExecutionPayloadEnvelope(ctx context.Context, blockID string, contentType string) (*RawResponse, error)
	// OpenRawDebugBeaconState opens a successful raw beacon state response without consuming its body.
	OpenRawDebugBeaconState(ctx context.Context, stateID string, contentType string) (*RawResponse, error)
	DepositSnapshot(ctx context.Context) (*types.DepositSnapshot, error)
	NodeIdentity(ctx context.Context) (*types.Identity, error)
}

ConsensusClient is an interface for executing RPC calls to the Ethereum node.

func NewConsensusClient

func NewConsensusClient(
	log logrus.FieldLogger,
	url string,
	client *http.Client,
	rawClient *http.Client,
	headers map[string]string,
	rawResponseObserver RawResponseObserver,
) ConsensusClient

NewConsensusClient creates a ConsensusClient. Both HTTP clients must be non-nil.

type HTTPStatusError added in v0.71.0

type HTTPStatusError struct {
	StatusCode  int
	RequestPath string
	RetryAfter  string
	BodyPrefix  string
}

HTTPStatusError describes a non-200 response from a raw endpoint.

func (*HTTPStatusError) Error added in v0.71.0

func (e *HTTPStatusError) Error() string

func (*HTTPStatusError) Unwrap added in v0.71.0

func (e *HTTPStatusError) Unwrap() error

Unwrap preserves ErrNotFound classification for HTTP 404 responses.

type RawResponse added in v0.71.0

type RawResponse struct {
	// Body is the managed response stream.
	Body io.ReadCloser
	// ContentType is the response's actual Content-Type.
	ContentType string
	// ContentLength is -1 when the response length is unknown, so length-based
	// completeness cannot be verified.
	ContentLength int64
	// Uncompressed reports whether net/http transparently decompressed the body.
	// Use Options.SetAPIClientAcceptEncoding to receive an encoded body without
	// automatic decompression.
	Uncompressed bool
	// Header is a clone of the response headers.
	Header http.Header
}

RawResponse streams a successful raw endpoint response. Opening the response only validates its status; callers must treat any read error as fatal and avoid committing partial output. The caller must close the response, including when a read fails or the body is only partially read.

func (*RawResponse) Close added in v0.71.0

func (r *RawResponse) Close() error

Close releases the response body. Repeated calls return the first close result.

func (*RawResponse) Read added in v0.71.0

func (r *RawResponse) Read(p []byte) (int, error)

Read reads from the response body.

type RawResponseObserver added in v0.71.0

type RawResponseObserver interface {
	RawResponseOpened()
	RawResponseClosed()
	RawResponseLeaked()
}

RawResponseObserver receives raw response body lifecycle events.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL