rpc

package
v0.0.0-...-c69f244 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalRequestOnly

func LocalRequestOnly(r *rpc.RequestInfo, i interface{}) error

LocalRequestOnly HTTP handler to restrict to only local connections

func LocalhostFilter

func LocalhostFilter() *ipfilter.IPFilter

LocalhostFilter creates a ipfilter object for localhost

func NewWSConn

func NewWSConn(conn *websocket.Conn, cfg *HTTPServerConfig) *subscription.WSConn

NewWSConn to create new WebSocket Connection struct

Types

type DotUpCodec

type DotUpCodec struct{}

DotUpCodec for overridding default jsonCodec

func NewDotUpCodec

func NewDotUpCodec() *DotUpCodec

NewDotUpCodec for creating instance of DocUpCodec

func (*DotUpCodec) NewRequest

func (c *DotUpCodec) NewRequest(r *http.Request) rpc.CodecRequest

NewRequest is overridden to inject our codec handler

type DotUpCodecRequest

type DotUpCodecRequest struct {
	*json2.CodecRequest
}

DotUpCodecRequest decodes and encodes a single request. UpCodecRequest implements gorilla/rpc.CodecRequest interface primarily by embedding the CodecRequest from gorilla/rpc/json. By selectively adding CodecRequest methods to UpCodecRequest, we can modify that behaviour while maintaining all the other remaining CodecRequest methods from gorilla's rpc/json implementation

func (*DotUpCodecRequest) Method

func (c *DotUpCodecRequest) Method() (string, error)

Method returns the decoded method as a string of the form "Service.Method" after checking for, and correcting a underscore and lowercase method name By being of lower depth in the struct , Method will replace the implementation of Method() on the embedded CodecRequest. Because the request data is part of the embedded json.CodecRequest, and unexported, we have to get the requested method name via the embedded CR's own method Method(). Essentially, this just intercepts the return value from the embedded gorilla/rpc/json.CodecRequest.Method(), checks/modifies it, and passes it on to the calling rpc server.

type HTTPServer

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

HTTPServer gateway for RPC server

func NewHTTPServer

func NewHTTPServer(cfg *HTTPServerConfig) *HTTPServer

NewHTTPServer creates a new http server and registers an associated rpc server

func (*HTTPServer) RegisterModules

func (h *HTTPServer) RegisterModules(mods []string)

RegisterModules registers the RPC services associated with the given API modules

func (*HTTPServer) ServeHTTP

func (h *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implemented to handle WebSocket connections

func (*HTTPServer) Start

func (h *HTTPServer) Start() error

Start registers the rpc handler function and starts the rpc http and websocket server

func (*HTTPServer) Stop

func (h *HTTPServer) Stop() error

Stop stops the server

type HTTPServerConfig

type HTTPServerConfig struct {
	LogLvl              log.Level
	BlockAPI            modules.BlockAPI
	StorageAPI          modules.StorageAPI
	NetworkAPI          modules.NetworkAPI
	CoreAPI             modules.CoreAPI
	BlockProducerAPI    modules.BlockProducerAPI
	BlockFinalityAPI    modules.BlockFinalityAPI
	TransactionQueueAPI modules.TransactionStateAPI
	RPCAPI              modules.RPCAPI
	SystemAPI           modules.SystemAPI
	SyncStateAPI        modules.SyncStateAPI
	SyncAPI             modules.SyncAPI
	NodeStorage         *runtime.NodeStorage
	RPC                 bool
	RPCExternal         bool
	RPCUnsafe           bool
	RPCUnsafeExternal   bool
	Host                string
	RPCPort             uint32
	WS                  bool
	WSExternal          bool
	WSUnsafe            bool
	WSUnsafeExternal    bool
	WSPort              uint32
	Modules             []string
}

HTTPServerConfig configures the HTTPServer

type Service

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

Service struct to hold rpc service data

func NewService

func NewService() *Service

NewService create a new instance of Service

func (*Service) BuildMethodNames

func (s *Service) BuildMethodNames(rcvr interface{}, name string)

BuildMethodNames takes receiver interface and populates rpcMethods array with available method names

func (*Service) Methods

func (s *Service) Methods() []string

Methods returns list of methods available via RPC call

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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