beaconhttp

package
v1.9.7-0...-cb92314 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Head      chainTag = 0
	Finalized chainTag = 1
	Justified chainTag = 2
	Genesis   chainTag = 3
)
View Source
var ErrorCantFindBeaconState = errors.New("Could not find beacon state")
View Source
var ErrorSszNotSupported = errors.New("This endpoint does not support SSZ response")

Functions

func EpochFromRequest

func EpochFromRequest(r *http.Request) (uint64, error)

func HandleEndpoint

func HandleEndpoint[T any](h EndpointHandler[T]) http.HandlerFunc

func HandleEndpointFunc

func HandleEndpointFunc[T any](h EndpointHandlerFunc[T]) http.HandlerFunc

func HashFromQueryParams

func HashFromQueryParams(r *http.Request, name string) (*common.Hash, error)

func StringFromRequest

func StringFromRequest(r *http.Request, name string) (string, error)

func StringListFromQueryParams

func StringListFromQueryParams(r *http.Request, name string) ([]string, error)

decode a list of strings from the query params

func Uint64FromQueryParams

func Uint64FromQueryParams(r *http.Request, name string) (*uint64, error)

uint64FromQueryParams retrieves a number from the query params, in base 10.

Types

type BeaconResponse

type BeaconResponse struct {
	Data                any
	Finalized           *bool
	Version             *clparams.StateVersion
	ExecutionOptimistic *bool

	Extra map[string]any
}

func NewBeaconResponse

func NewBeaconResponse(data any) *BeaconResponse

func (*BeaconResponse) EncodeSSZ

func (b *BeaconResponse) EncodeSSZ(xs []byte) ([]byte, error)

func (*BeaconResponse) EncodingSizeSSZ

func (b *BeaconResponse) EncodingSizeSSZ() int

func (*BeaconResponse) MarshalJSON

func (b *BeaconResponse) MarshalJSON() ([]byte, error)

func (*BeaconResponse) With

func (r *BeaconResponse) With(key string, value any) (out *BeaconResponse)

func (*BeaconResponse) WithFinalized

func (r *BeaconResponse) WithFinalized(finalized bool) (out *BeaconResponse)

func (*BeaconResponse) WithOptimistic

func (r *BeaconResponse) WithOptimistic(optimistic bool) (out *BeaconResponse)

func (*BeaconResponse) WithVersion

func (r *BeaconResponse) WithVersion(version clparams.StateVersion) (out *BeaconResponse)

type EndpointError

type EndpointError struct {
	Code        int      `json:"code"`
	Message     string   `json:"message"`
	Stacktraces []string `json:"stacktraces,omitempty"`
	// contains filtered or unexported fields
}

func NewEndpointError

func NewEndpointError(code int, err error) *EndpointError

func WrapEndpointError

func WrapEndpointError(err error) *EndpointError

func (EndpointError) Error

func (e EndpointError) Error() string

func (EndpointError) Unwrap

func (e EndpointError) Unwrap() error

func (*EndpointError) WriteTo

func (e *EndpointError) WriteTo(w http.ResponseWriter)

type EndpointHandler

type EndpointHandler[T any] interface {
	Handle(w http.ResponseWriter, r *http.Request) (T, error)
}

type EndpointHandlerFunc

type EndpointHandlerFunc[T any] func(w http.ResponseWriter, r *http.Request) (T, error)

func (EndpointHandlerFunc[T]) Handle

func (e EndpointHandlerFunc[T]) Handle(w http.ResponseWriter, r *http.Request) (T, error)

type IntStr

type IntStr int

func (IntStr) MarshalJSON

func (i IntStr) MarshalJSON() ([]byte, error)

func (*IntStr) UnmarshalJSON

func (i *IntStr) UnmarshalJSON(b []byte) error

type SegmentID

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

Represent either state id or block id

func BlockIdFromRequest

func BlockIdFromRequest(r *http.Request) (*SegmentID, error)

func StateIdFromRequest

func StateIdFromRequest(r *http.Request) (*SegmentID, error)

func (*SegmentID) Finalized

func (c *SegmentID) Finalized() bool

func (*SegmentID) Genesis

func (c *SegmentID) Genesis() bool

func (*SegmentID) GetRoot

func (c *SegmentID) GetRoot() *common.Hash

func (*SegmentID) GetSlot

func (c *SegmentID) GetSlot() *uint64

func (*SegmentID) Head

func (c *SegmentID) Head() bool

func (*SegmentID) Justified

func (c *SegmentID) Justified() bool

Jump to

Keyboard shortcuts

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