rpc

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 25 Imported by: 22

Documentation

Index

Constants

View Source
const (
	INVALID_REQUEST  = -32600
	METHOD_NOT_FOUND = -32601
	INVALID_PARAMS   = -32602
	INTERNAL_ERROR   = -32603
	PARSE_ERROR      = -32700
)

JSON-RPC 2.0 error codes.

View Source
const AccountsRingMutexCount = 100
View Source
const MaxBlockLookback = 1000

Magic! Should probably be configurable, but not shouldn't be so huge we end up DoSing ourselves.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountHumanReadable added in v0.18.0

type AccountHumanReadable struct {
	Address     acm.Address
	PublicKey   acm.PublicKey
	Sequence    uint64
	Balance     uint64
	Code        []string
	StorageRoot string
	Permissions []string
	Roles       []string
}

type Codec

type Codec interface {
	EncodeBytes(interface{}) ([]byte, error)
	Encode(interface{}, io.Writer) error
	DecodeBytes(interface{}, []byte) error
	DecodeBytesPtr(interface{}, []byte) error
	Decode(interface{}, io.Reader) error
}

Used for rpc request and response data.

type Peer added in v0.18.0

type Peer struct {
	NodeInfo   p2p.NodeInfo
	IsOutbound bool
}

type ProfilerConfig added in v0.18.0

type ProfilerConfig struct {
	Disabled      bool
	ListenAddress string
}

func DefaultProfilerConfig added in v0.18.0

func DefaultProfilerConfig() *ProfilerConfig

type RPCConfig added in v0.18.0

type RPCConfig struct {
	V0       *V0Config       `json:",omitempty" toml:",omitempty"`
	TM       *TMConfig       `json:",omitempty" toml:",omitempty"`
	Profiler *ProfilerConfig `json:",omitempty" toml:",omitempty"`
}

func DefaultRPCConfig added in v0.18.0

func DefaultRPCConfig() *RPCConfig

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RPCError MUST be included in the Response object if an error occured

func (RPCError) Error added in v0.18.0

func (err RPCError) Error() string

type RPCErrorResponse

type RPCErrorResponse struct {
	Error   *RPCError `json:"error"`
	Id      string    `json:"id"`
	JSONRPC string    `json:"jsonrpc"`
}

RPCErrorResponse MUST NOT contain the result member if an error occured

func (*RPCErrorResponse) AssertIsRPCResponse

func (rpcErrorResponse *RPCErrorResponse) AssertIsRPCResponse() bool

AssertIsRPCResponse implements a marker method for RPCErrorResponse to implement the interface RPCResponse

type RPCRequest

type RPCRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
	Id      string          `json:"id"`
}

Request and Response objects. Id is a string. Error data not used. Refer to JSON-RPC specification http://www.jsonrpc.org/specification

func NewRPCRequest added in v0.16.2

func NewRPCRequest(id string, method string, params json.RawMessage) *RPCRequest

Create a new RPC request. This is the generic struct that is passed to RPC methods

type RPCResponse

type RPCResponse interface {
	AssertIsRPCResponse() bool
}

RPCResponse MUST follow the JSON-RPC specification for Response object reference: http://www.jsonrpc.org/specification#response_object

func NewRPCErrorResponse

func NewRPCErrorResponse(id string, code int, message string) RPCResponse

NewRPCErrorResponse creates a new error-response object from the error code and message

func NewRPCResponse

func NewRPCResponse(id string, res interface{}) RPCResponse

NewRPCResponse creates a new response object from a result

type RPCResultResponse

type RPCResultResponse struct {
	Result  interface{} `json:"result"`
	Id      string      `json:"id"`
	JSONRPC string      `json:"jsonrpc"`
}

RPCResultResponse MUST NOT contain the error member if no error occurred

func (*RPCResultResponse) AssertIsRPCResponse

func (rpcResultResponse *RPCResultResponse) AssertIsRPCResponse() bool

AssertIsRPCResponse implements a marker method for RPCResultResponse to implement the interface RPCResponse

type ResultBroadcastTx added in v0.18.0

type ResultBroadcastTx struct {
	txs.Receipt
}

func (ResultBroadcastTx) MarshalJSON added in v0.18.0

func (rbt ResultBroadcastTx) MarshalJSON() ([]byte, error)

func (ResultBroadcastTx) UnmarshalJSON added in v0.18.0

func (rbt ResultBroadcastTx) UnmarshalJSON(data []byte) (err error)

type ResultCall added in v0.18.0

type ResultCall struct {
	execution.Call
}

func (ResultCall) MarshalJSON added in v0.18.0

func (rc ResultCall) MarshalJSON() ([]byte, error)

func (*ResultCall) UnmarshalJSON added in v0.18.0

func (rc *ResultCall) UnmarshalJSON(data []byte) (err error)

type ResultChainId added in v0.18.0

type ResultChainId struct {
	ChainName   string
	ChainId     string
	GenesisHash []byte
}

type ResultDumpConsensusState added in v0.18.0

type ResultDumpConsensusState struct {
	RoundState      *ctypes.RoundState
	PeerRoundStates []*ctypes.PeerRoundState
}

type ResultDumpStorage added in v0.18.0

type ResultDumpStorage struct {
	StorageRoot  []byte
	StorageItems []StorageItem
}

type ResultEvent added in v0.18.0

type ResultEvent struct {
	Event         string
	TMEventData   *tm_types.TMEventData     `json:",omitempty"`
	EventDataTx   *exe_events.EventDataTx   `json:",omitempty"`
	EventDataCall *evm_events.EventDataCall `json:",omitempty"`
	EventDataLog  *evm_events.EventDataLog  `json:",omitempty"`
}

func NewResultEvent added in v0.18.0

func NewResultEvent(event string, eventData interface{}) (*ResultEvent, error)

Map any supported event data element to our ResultEvent sum type

func (ResultEvent) EventDataNewBlock added in v0.18.0

func (resultEvent ResultEvent) EventDataNewBlock() *tm_types.EventDataNewBlock

type ResultGeneratePrivateAccount added in v0.18.0

type ResultGeneratePrivateAccount struct {
	PrivateAccount *acm.ConcretePrivateAccount
}

type ResultGenesis added in v0.18.0

type ResultGenesis struct {
	Genesis genesis.GenesisDoc
}

type ResultGetAccount added in v0.18.0

type ResultGetAccount struct {
	Account *acm.ConcreteAccount
}

type ResultGetAccountHumanReadable added in v0.18.0

type ResultGetAccountHumanReadable struct {
	Account *AccountHumanReadable
}

type ResultGetBlock added in v0.18.0

type ResultGetBlock struct {
	BlockMeta *tm_types.BlockMeta
	Block     *tm_types.Block
}

type ResultGetName added in v0.18.0

type ResultGetName struct {
	Entry *execution.NameRegEntry
}

type ResultGetStorage added in v0.18.0

type ResultGetStorage struct {
	Key   []byte
	Value []byte
}

type ResultListAccounts added in v0.18.0

type ResultListAccounts struct {
	BlockHeight uint64
	Accounts    []*acm.ConcreteAccount
}

type ResultListBlocks added in v0.18.0

type ResultListBlocks struct {
	LastHeight uint64
	BlockMetas []*tm_types.BlockMeta
}

type ResultListNames added in v0.18.0

type ResultListNames struct {
	BlockHeight uint64
	Names       []*execution.NameRegEntry
}

type ResultListUnconfirmedTxs added in v0.18.0

type ResultListUnconfirmedTxs struct {
	NumTxs int
	Txs    []txs.Wrapper
}

type ResultListValidators added in v0.18.0

type ResultListValidators struct {
	BlockHeight         uint64
	BondedValidators    []*acm.ConcreteValidator
	UnbondingValidators []*acm.ConcreteValidator
}

type ResultNetInfo added in v0.18.0

type ResultNetInfo struct {
	Listening bool
	Listeners []string
	Peers     []*Peer
}

type ResultPeers added in v0.18.0

type ResultPeers struct {
	Peers []*Peer
}

type ResultSignTx added in v0.18.0

type ResultSignTx struct {
	Tx txs.Wrapper
}

type ResultStatus added in v0.18.0

type ResultStatus struct {
	NodeInfo          p2p.NodeInfo
	GenesisHash       []byte
	PubKey            acm.PublicKey
	LatestBlockHash   []byte
	LatestBlockHeight uint64
	LatestBlockTime   int64
	NodeVersion       string
}

type ResultSubscribe added in v0.18.0

type ResultSubscribe struct {
	EventID        string
	SubscriptionID string
}

type ResultUnsubscribe added in v0.18.0

type ResultUnsubscribe struct {
	SubscriptionID string
}

type Service added in v0.18.0

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

Base service that provides implementation for all underlying RPC methods

func NewService added in v0.18.0

func NewService(ctx context.Context, state state.Iterable, nameReg execution.NameRegIterable,
	checker state.Reader, subscribable event.Subscribable, blockchain bcm.Blockchain, keyClient keys.KeyClient,
	transactor *execution.Transactor, nodeView *query.NodeView, logger *logging.Logger) *Service

func NewSubscribableService added in v0.18.0

func NewSubscribableService(subscribable event.Subscribable, logger *logging.Logger) *Service

Provides a sub-service with only the subscriptions methods

func (*Service) ChainId added in v0.18.0

func (s *Service) ChainId() (*ResultChainId, error)

func (*Service) DumpConsensusState added in v0.18.0

func (s *Service) DumpConsensusState() (*ResultDumpConsensusState, error)

func (*Service) DumpStorage added in v0.18.0

func (s *Service) DumpStorage(address acm.Address) (*ResultDumpStorage, error)

func (*Service) GeneratePrivateAccount added in v0.18.0

func (s *Service) GeneratePrivateAccount() (*ResultGeneratePrivateAccount, error)

func (*Service) Genesis added in v0.18.0

func (s *Service) Genesis() (*ResultGenesis, error)

func (*Service) GetAccount added in v0.18.0

func (s *Service) GetAccount(address acm.Address) (*ResultGetAccount, error)

Accounts

func (*Service) GetAccountHumanReadable added in v0.18.0

func (s *Service) GetAccountHumanReadable(address acm.Address) (*ResultGetAccountHumanReadable, error)

func (*Service) GetBlock added in v0.18.0

func (s *Service) GetBlock(height uint64) (*ResultGetBlock, error)

func (*Service) GetName added in v0.18.0

func (s *Service) GetName(name string) (*ResultGetName, error)

Name registry

func (*Service) GetStorage added in v0.18.0

func (s *Service) GetStorage(address acm.Address, key []byte) (*ResultGetStorage, error)

func (*Service) ListAccounts added in v0.18.0

func (s *Service) ListAccounts(predicate func(acm.Account) bool) (*ResultListAccounts, error)

func (*Service) ListBlocks added in v0.18.0

func (s *Service) ListBlocks(minHeight, maxHeight uint64) (*ResultListBlocks, error)

Returns the current blockchain height and metadata for a range of blocks between minHeight and maxHeight. Only returns maxBlockLookback block metadata from the top of the range of blocks. Passing 0 for maxHeight sets the upper height of the range to the current blockchain height.

func (*Service) ListNames added in v0.18.0

func (s *Service) ListNames(predicate func(*execution.NameRegEntry) bool) (*ResultListNames, error)

func (*Service) ListUnconfirmedTxs added in v0.18.0

func (s *Service) ListUnconfirmedTxs(maxTxs int) (*ResultListUnconfirmedTxs, error)

func (*Service) ListValidators added in v0.18.0

func (s *Service) ListValidators() (*ResultListValidators, error)

func (*Service) MempoolAccounts added in v0.18.0

func (s *Service) MempoolAccounts() *execution.Accounts

Get pending account state residing in the mempool

func (*Service) NetInfo added in v0.18.0

func (s *Service) NetInfo() (*ResultNetInfo, error)

func (*Service) Peers added in v0.18.0

func (s *Service) Peers() (*ResultPeers, error)

func (*Service) State added in v0.18.0

func (s *Service) State() state.Reader

func (*Service) Status added in v0.18.0

func (s *Service) Status() (*ResultStatus, error)

func (*Service) Subscribe added in v0.18.0

func (s *Service) Subscribe(ctx context.Context, subscriptionID string, eventID string,
	callback func(resultEvent *ResultEvent) bool) error

func (*Service) Transactor added in v0.18.0

func (s *Service) Transactor() *execution.Transactor

Get a Transactor providing methods for delegating signing and the core BroadcastTx function for publishing transactions to the network

func (*Service) Unsubscribe added in v0.18.0

func (s *Service) Unsubscribe(ctx context.Context, subscriptionID string) error

type StorageItem added in v0.18.0

type StorageItem struct {
	Key   []byte
	Value []byte
}

type TMConfig added in v0.18.0

type TMConfig struct {
	Disabled      bool
	ListenAddress string
}

func DefaultTMConfig added in v0.18.0

func DefaultTMConfig() *TMConfig

type V0Config added in v0.18.0

type V0Config struct {
	Disabled bool
	Server   *server.ServerConfig
}

func DefaultV0Config added in v0.18.0

func DefaultV0Config() *V0Config

Directories

Path Synopsis
tm
v0

Jump to

Keyboard shortcuts

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