rpc

package
v0.0.0-...-f34ac1a Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientCodec

func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

NewClientCodec returns a new rpc.ClientCodec using JSON-RPC 2.0 on conn.

func NewJSONCodec

func NewJSONCodec(conn io.ReadWriteCloser, srv *rpc.Server) rpc.ServerCodec

NewJSONCodec returns a new rpc.ServerCodec using JSON-RPC on conn.

func ServeConn

func ServeConn(conn io.ReadWriteCloser)

ServeConn runs the JSON-RPC server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn with go-routine.

Types

type BatchArg

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

BatchArg is a param for internal RPC JSONRPC2.Batch.

type Client

type Client struct {
	*rpc.Client
	// contains filtered or unexported fields
}

Client represents a JSON RPC 2.0 Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously.

It also provides all methods of net/rpc Client.

func Dial

func Dial(network, address string) (*Client, error)

Dial connects to a JSON-RPC 2.0 server at the specified network address.

func NewClient

func NewClient(conn io.ReadWriteCloser) *Client

NewClient returns a new Client to handle requests to the set of services at the other end of the connection.

func NewClientWithCodec

func NewClientWithCodec(codec rpc.ClientCodec) *Client

NewClientWithCodec returns a new Client using the given rpc.ClientCodec.

func (Client) Notify

func (c Client) Notify(serviceMethod string, args interface{}) error

Notify try to invoke the named function. It return error only in case it wasn't able to send request.

type CurrentBlock

type CurrentBlock struct {
	HeadHash   string   `json:"headHash"`
	Height     uint64   `json:"height"`
	Timestamp  *big.Int `json:"timestamp"`
	Difficulty *big.Int `json:"difficulty"`
	Creator    string   `json:"creator"`
	TxCount    int      `json:"txcount"`
}

CurrentBlock is the informations about the best block

type Error

type Error struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

Error represent JSON-RPC 2.0 "Error object".

func NewError

func NewError(code int, message string) *Error

NewError returns an Error with given code and message.

func ServerError

func ServerError(rpcerr error) *Error

ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.

func (*Error) Error

func (e *Error) Error() string

Error returns JSON representation of Error.

type GetBlockByHeightRequest

type GetBlockByHeightRequest struct {
	Height int64
	FullTx bool
}

GetBlockByHeightRequest request param for GetBlockByHeight api

type JSONRPC2

type JSONRPC2 struct{}

JSONRPC2 is an internal RPC service used to process batch requests.

func (JSONRPC2) Batch

func (JSONRPC2) Batch(arg BatchArg, replies *[]*json.RawMessage) (err error)

Batch is an internal RPC method used to process batch requests.

type MinerInfo

type MinerInfo struct {
	Coinbase           common.Address
	CurrentBlockHeight uint64
	HeaderHash         common.Hash
}

MinerInfo miner simple info

type MonitorRPC

type MonitorRPC struct {
	Debug bool
	// contains filtered or unexported fields
}

MonitorRPC json_rpc client

func NewSeeleRPC

func NewSeeleRPC(url string, options ...func(rpc *MonitorRPC)) *MonitorRPC

NewSeeleRPC create new json_rpc

func (*MonitorRPC) CurrentBlock

func (rpc *MonitorRPC) CurrentBlock(h int64, fullTx bool) (currentBlock *CurrentBlock, err error)

CurrentBlock returns the current block info.

func (*MonitorRPC) GetInfo

func (rpc *MonitorRPC) GetInfo() (result map[string]interface{}, err error)

GetInfo gets the account address that mining rewards will be send to.

func (*MonitorRPC) NodeInfo

func (rpc *MonitorRPC) NodeInfo() (nodeInfo *NodeInfo, err error)

NodeInfo returns the current node info.

func (*MonitorRPC) NodeStats

func (rpc *MonitorRPC) NodeStats() (nodeStats *NodeStats, err error)

NodeStats returns the current node info.

type NodeInfo

type NodeInfo struct {
	Name       string `json:"name"`
	Node       string `json:"node"`
	Port       int    `json:"port"`
	NetVersion string `json:"netVersion"`
	Protocol   string `json:"protocol"`
	API        string `json:"api"`
	Os         string `json:"os"`
	OsVer      string `json:"os_v"`
	Client     string `json:"client"`
	History    bool   `json:"canUpdateHistory"`
	Shard      uint   `json:"shard"`
}

NodeInfo is the collection of meta information about a node that is displayed on the monitoring page.

type NodeStats

type NodeStats struct {
	Active   bool   `json:"active"`
	Syncing  bool   `json:"syncing"`
	Mining   bool   `json:"mining"`
	Hashrate uint64 `json:"hashrate"`
	Peers    int    `json:"peers"`
}

NodeStats is the information about the local node.

Jump to

Keyboard shortcuts

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