rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

RPC implementation in DOID node is based on github.com/ethereum/go-ethereum/rpc that follows JSON-RPC 2.0.

Example

request:

{"jsonrpc": "2.0", "method": "doid_getBlockByHeight", "params": [1], "id": 1}

response:

{"jsonrpc":"2.0","id":1,"result":{"header":{"parentHash":"","sha3Uncles":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","miner":"","stateRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","transactionsRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","receiptsRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","difficulty":16777216,"height":1,"timestamp":0,"extraData":"","nonce":"0x0000000000000000"},"data":{"txs":null},"uncles":null,"receipts":null}}

Request

`method` in request is defined in `{namespace}_{methodName}` format where

  • `namespace` is defined when registering a struct by calling RegisterName, `API List` below shows namespaces and corresponding structs
  • `methodName` is public methods of the struct in uncapitalized form

`params` are the parameters of the public method

Response

`result` in response is the return values of the public method

Subscriptions

Subscription is supported in websocket streams.

Method is defined in `{namespace}_subscribe` format. First param is uncapitalized public method name that returns a github.com/ethereum/go-ethereum/rpc.Subscription

For example:

{"jsonrpc": "2.0", "method": "doid_subscribe", "params": ["newHeads"], "id": 1}

will execute github.com/DOIDFoundation/node/core.API.NewHeads

Result will be like:

{"jsonrpc":"2.0","id":1,"result":"0xd37be67a9aaa143969d24cada292a445"}
{"jsonrpc":"2.0","method":"doid_subscription","params":{"subscription":"0xd37be67a9aaa143969d24cada292a445","result":{"header":{"parentHash":"000000A891B5201E56D50B52D619B442E6E89C6AC66ADAF919F3BAFF805924C5","sha3Uncles":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","miner":"","stateRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","transactionsRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","receiptsRoot":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","difficulty":2157515,"height":5286,"timestamp":1688641961,"extraData":"","nonce":"0x45b97c08b2d57274"},"data":{"txs":[]},"uncles":[],"receipts":[]}}}

API List

Here are some namespaces and their corresponding structs, methods can be found from the public methods of each struct.

`doid`

`node`

`network`

`txpool`

Index

Constants

This section is empty.

Variables

View Source
var APIs []rpc.API // List of APIs currently provided by the network
View Source
var DefaultConfig = Config{
	HTTPTimeouts: rpc.DefaultHTTPTimeouts,
}

DefaultConfig returns a default configuration for the RPC server

Functions

func RegisterName

func RegisterName(name string, receiver interface{})

Types

type Config

type Config struct {
	// HTTPTimeouts allows for customization of the timeout values used by the HTTP RPC
	// interface.
	HTTPTimeouts rpc.HTTPTimeouts
}

Defines the configuration options for the RPC server

type RPC

type RPC struct {
	service.BaseService
	// contains filtered or unexported fields
}

func NewRPC

func NewRPC(logger log.Logger) *RPC

func (*RPC) OnStart

func (r *RPC) OnStart() error

func (*RPC) OnStop

func (r *RPC) OnStop()

Jump to

Keyboard shortcuts

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