rpc

package
v0.0.0-...-27cef4d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 18 Imported by: 3 modules, 11 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArgument      = errors.New("invalid argument")
	ErrInvalidArgumentIndex = errors.New("invalid argument index")
	ErrInvalidArgumentType  = errors.New("invalid argument type")
	ErrInvalidMethod        = errors.New("invalid method")
)

errors

Functions

This section is empty.

Types

type Argument

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

Argument parses rpc arguments

func NewArgument

func NewArgument(args []*string) *Argument

NewArgument returns a Argument

func (*Argument) Float32

func (arg *Argument) Float32(index int) (float32, error)

Float32 returns a float32 value of the index

func (*Argument) Float64

func (arg *Argument) Float64(index int) (float64, error)

Float64 returns a float64 value of the index

func (*Argument) Int

func (arg *Argument) Int(index int) (int, error)

Int returns a int value of the index

func (*Argument) Len

func (arg *Argument) Len() int

Len returns length of arguments

func (*Argument) String

func (arg *Argument) String(index int) (string, error)

Strings returns a string value of the index

func (*Argument) Uint8

func (arg *Argument) Uint8(index int) (uint8, error)

Uint8 returns a uint8 value of the index

func (*Argument) Uint16

func (arg *Argument) Uint16(index int) (uint16, error)

Uint16 returns a uint16 value of the index

func (*Argument) Uint32

func (arg *Argument) Uint32(index int) (uint32, error)

Uint32 returns a uint32 value of the index

func (*Argument) Uint64

func (arg *Argument) Uint64(index int) (uint64, error)

Uint64 returns a uint64 value of the index

type EventNotify

type EventNotify struct {
	Type      string                 `json:"type"`
	Timestamp int64                  `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
}

EventNotify is a notification of events

type Handler

type Handler func(kn *kernel.Kernel, ID interface{}, arg *Argument) (interface{}, error)

Handler handles a rpc method

type JRPCRequest

type JRPCRequest struct {
	JSONRPC string         `json:"jsonrpc"`
	ID      interface{}    `json:"id"`
	Method  string         `json:"method"`
	Params  []*json.Number `json:"params"`
}

JRPCRequest is a jrpc request

type JRPCResponse

type JRPCResponse struct {
	JSONRPC string      `json:"jsonrpc"`
	ID      interface{} `json:"id"`
	Result  interface{} `json:"result"`
	Error   interface{} `json:"error"`
}

JRPCResponse is a jrpc response

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager provides a rpc server

func NewManager

func NewManager() *Manager

NewManager returns a Manager

func (*Manager) Add

func (rm *Manager) Add(Method string, fn Handler)

Add adds a rpc methods to the manager

func (*Manager) AfterProcessBlock

func (rm *Manager) AfterProcessBlock(kn *kernel.Kernel, b *block.Block, s *block.ObserverSigned, ctx *data.Context)

AfterProcessBlock called when processed block to the chain

func (*Manager) AfterPushTransaction

func (rm *Manager) AfterPushTransaction(kn *kernel.Kernel, tx transaction.Transaction, sigs []common.Signature)

AfterPushTransaction called when pushed a transaction to the transaction pool

func (*Manager) Close

func (rm *Manager) Close()

Close terminates the rpc manager

func (*Manager) DebugLog

func (rm *Manager) DebugLog(kn *kernel.Kernel, args ...interface{})

DebugLog provides internal debug logs to handlers

func (*Manager) DoTransactionBroadcast

func (rm *Manager) DoTransactionBroadcast(kn *kernel.Kernel, msg *message_def.TransactionMessage)

DoTransactionBroadcast called when a transaction need to be broadcast

func (*Manager) OnProcessBlock

func (rm *Manager) OnProcessBlock(kn *kernel.Kernel, b *block.Block, s *block.ObserverSigned, ctx *data.Context) error

OnProcessBlock called when processing a block to the chain (error prevent processing block)

func (*Manager) OnPushTransaction

func (rm *Manager) OnPushTransaction(kn *kernel.Kernel, tx transaction.Transaction, sigs []common.Signature) error

OnPushTransaction called when pushing a transaction to the transaction pool (error prevent push transaction)

func (*Manager) Run

func (rm *Manager) Run(kn *kernel.Kernel, Bind string) error

Run runs a server to provide RPC a http service and a websocket service

Jump to

Keyboard shortcuts

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