rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.

The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.

The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockFinalizedListener added in v0.2.0

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

BlockFinalizedListener to handle listening for finalized blocks

func (*BlockFinalizedListener) Listen added in v0.2.0

func (l *BlockFinalizedListener) Listen()

Listen implementation of Listen interface to listen for channel changes

type BlockListener added in v0.2.0

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

BlockListener to handle listening for blocks channel

func (*BlockListener) Listen added in v0.2.0

func (l *BlockListener) Listen()

Listen implementation of Listen interface to listen for channel changes

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 behavior 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 ErrorMessageJSON

type ErrorMessageJSON struct {
	Code    *big.Int `json:"code"`
	Message string   `json:"message"`
}

ErrorMessageJSON json for error messages

type ErrorResponseJSON

type ErrorResponseJSON struct {
	Jsonrpc string            `json:"jsonrpc"`
	Error   *ErrorMessageJSON `json:"error"`
	ID      float64           `json:"id"`
}

ErrorResponseJSON json for error responses

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.Lvl
	BlockAPI            modules.BlockAPI
	StorageAPI          modules.StorageAPI
	NetworkAPI          modules.NetworkAPI
	CoreAPI             modules.CoreAPI
	BlockProducerAPI    modules.BlockProducerAPI
	RuntimeAPI          modules.RuntimeAPI
	TransactionQueueAPI modules.TransactionStateAPI
	RPCAPI              modules.RPCAPI
	SystemAPI           modules.SystemAPI
	Host                string
	RPCPort             uint32
	WSEnabled           bool
	WSPort              uint32
	Modules             []string
}

HTTPServerConfig configures the HTTPServer

type Listener added in v0.2.0

type Listener interface {
	Listen()
}

Listener interface for functions that define Listener related functions

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

type StorageChangeListener added in v0.2.0

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

StorageChangeListener for listening to state change channels

func (*StorageChangeListener) Listen added in v0.2.0

func (l *StorageChangeListener) Listen()

Listen implementation of Listen interface to listen for channel changes

type SubscriptionBaseResponseJSON

type SubscriptionBaseResponseJSON struct {
	Jsonrpc string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
}

SubscriptionBaseResponseJSON for base json response

type SubscriptionResponseJSON

type SubscriptionResponseJSON struct {
	Jsonrpc string  `json:"jsonrpc"`
	Result  int     `json:"result"`
	ID      float64 `json:"id"`
}

SubscriptionResponseJSON for json subscription responses

type WSConn added in v0.2.0

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

WSConn struct to hold WebSocket Connection references

func NewWSConn added in v0.2.0

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

NewWSConn to create new WebSocket Connection struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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