serve

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultListenAddress = "0.0.0.0:8546"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Events

type Events interface {
	// Subscribe subscribes to specific events
	Subscribe([]events.Type) *events.Subscription

	// CancelSubscription cancels the given subscription
	CancelSubscription(events.SubscriptionID)
}

Events is the interface for event passing

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(h http.Handler, addr string, logger *zap.Logger) *HTTPServer

func (*HTTPServer) Serve

func (s *HTTPServer) Serve(ctx context.Context) error

Serve serves the JSON-RPC server

type Handler

type Handler func(metadata *metadata.Metadata, params []any) (any, *spec.BaseJSONError)

Handler executes a method with accompanying data such as metadata and params

type JSONRPC

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

JSONRPC is the JSONRPC server instance, that is capable of handling both HTTP and WS requests

func NewJSONRPC

func NewJSONRPC(events Events, opts ...Option) *JSONRPC

NewJSONRPC creates a new instance of the JSONRPC server

func (*JSONRPC) RegisterBlockEndpoints

func (j *JSONRPC) RegisterBlockEndpoints(db block.Storage)

RegisterBlockEndpoints registers the block endpoints

func (*JSONRPC) RegisterGasEndpoints added in v0.5.3

func (j *JSONRPC) RegisterGasEndpoints(db gas.Storage)

RegisterGasPriceEndpoints registers the gas price endpoints

func (*JSONRPC) RegisterHandler

func (j *JSONRPC) RegisterHandler(method string, handler Handler)

RegisterHandler registers a new method handler, overwriting existing ones, if any

func (*JSONRPC) RegisterSubEndpoints

func (j *JSONRPC) RegisterSubEndpoints(db storage.Storage)

func (*JSONRPC) RegisterTxEndpoints

func (j *JSONRPC) RegisterTxEndpoints(db tx.Storage)

RegisterTxEndpoints registers the transaction endpoints

func (*JSONRPC) SetupRoutes

func (j *JSONRPC) SetupRoutes(mux *chi.Mux) *chi.Mux

SetupRoutes sets up the request router for the indexer service

func (*JSONRPC) UnregisterHandler

func (j *JSONRPC) UnregisterHandler(method string)

UnregisterHandler removes the method handler for the specified method, if any

type Option

type Option func(s *JSONRPC)

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets the logger to be used with the JSON-RPC server

Directories

Path Synopsis
handlers
gas
tx
ws

Jump to

Keyboard shortcuts

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