jsonrpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNewPayloadSyncing = errors.New("newPayload status is SYNCING")

ErrNewPayloadSyncing is returned when engine_newPayload returns SYNCING status.

Functions

func IsSyncingError

func IsSyncingError(err error) bool

IsSyncingError checks if the error is a SYNCING status error.

Types

type ComposedValidator

type ComposedValidator struct {
	// contains filtered or unexported fields
}

ComposedValidator runs multiple validators in sequence.

func NewComposedValidator

func NewComposedValidator(validators ...Validator) *ComposedValidator

NewComposedValidator creates a validator that runs multiple validators in sequence.

func (*ComposedValidator) Validate

func (v *ComposedValidator) Validate(method string, resp *Response) error

Validate runs all validators in sequence, returning the first error encountered.

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a JSON-RPC 2.0 error object.

type ErrorValidator

type ErrorValidator struct{}

ErrorValidator fails if the response contains an error field.

func (*ErrorValidator) Validate

func (v *ErrorValidator) Validate(_ string, resp *Response) error

Validate checks if the response has a JSON-RPC error.

type ForkchoiceUpdatedResult

type ForkchoiceUpdatedResult struct {
	PayloadStatus PayloadStatus `json:"payloadStatus"`
	PayloadID     string        `json:"payloadId,omitempty"`
}

ForkchoiceUpdatedResult represents the result of an engine_forkchoiceUpdated call.

type ForkchoiceUpdatedValidator

type ForkchoiceUpdatedValidator struct{}

ForkchoiceUpdatedValidator fails if engine_forkchoiceUpdated* responses don't have VALID status.

func (*ForkchoiceUpdatedValidator) Validate

func (v *ForkchoiceUpdatedValidator) Validate(method string, resp *Response) error

Validate checks if engine_forkchoiceUpdated responses have VALID status.

type NewPayloadResult

type NewPayloadResult struct {
	Status          string `json:"status"`
	LatestValidHash string `json:"latestValidHash,omitempty"`
	ValidationError string `json:"validationError,omitempty"`
}

NewPayloadResult represents the result of an engine_newPayload call.

type NewPayloadValidator

type NewPayloadValidator struct{}

NewPayloadValidator fails if engine_newPayload* responses don't have VALID status.

func (*NewPayloadValidator) Validate

func (v *NewPayloadValidator) Validate(method string, resp *Response) error

Validate checks if engine_newPayload responses have VALID status.

type PayloadStatus

type PayloadStatus struct {
	Status          string `json:"status"`
	LatestValidHash string `json:"latestValidHash,omitempty"`
	ValidationError string `json:"validationError,omitempty"`
}

PayloadStatus represents the payload status in forkchoiceUpdated responses.

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *Error          `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response.

func Parse

func Parse(data string) (*Response, error)

Parse parses a JSON-RPC response from a string.

func (*Response) ParseResult

func (r *Response) ParseResult(v any) error

ParseResult parses the result field into the provided type.

type Validator

type Validator interface {
	Validate(method string, resp *Response) error
}

Validator validates JSON-RPC responses.

func DefaultValidator

func DefaultValidator() Validator

DefaultValidator returns a composed validator with ErrorValidator, NewPayloadValidator, and ForkchoiceUpdatedValidator.

Jump to

Keyboard shortcuts

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