apiserver

package
v0.0.0-...-ee6f1e6 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: LGPL-3.0 Imports: 14 Imported by: 0

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")
	ErrExistSubName         = errors.New("exist sub name")
)

errors

Functions

This section is empty.

Types

type APIServer

type APIServer struct {
	types.ServiceBase
	sync.Mutex
	// contains filtered or unexported fields
}

APIServer provides json rpc and web service for the chain

func NewAPIServer

func NewAPIServer() *APIServer

NewAPIServer returns a APIServer

func (*APIServer) Init

Init called when initialize service

func (*APIServer) JRPC

func (s *APIServer) JRPC(SubName string) (*JRPCSub, error)

JRPC provides the json rpc feature as a SubName.FunctionName methods

func (*APIServer) Name

func (s *APIServer) Name() string

Name returns the name of the service

func (*APIServer) OnBlockConnected

func (s *APIServer) OnBlockConnected(b *types.Block, events []types.Event, loader types.Loader)

OnBlockConnected called when a block is connected to the chain

func (*APIServer) OnLoadChain

func (s *APIServer) OnLoadChain(loader types.Loader) error

OnLoadChain called when the chain loaded

func (*APIServer) OnTransactionInPoolExpired

func (s *APIServer) OnTransactionInPoolExpired(txs []types.Transaction)

OnLoadChain called when the chain loaded

func (*APIServer) Run

func (s *APIServer) Run(BindAddress string) error

Run starts web service of the apiserver

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) 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

func (*Argument) Uint8

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

Uint8 returns a uint8 value of the index

type Handler

type Handler func(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  []interface{} `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 JRPCSub

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

JRPCSub provides the json rpc feature of the sub name

func NewJRPCSub

func NewJRPCSub() *JRPCSub

NewJRPCSub returns a JRPCSub

func (*JRPCSub) Set

func (s *JRPCSub) Set(Method string, h Handler)

Set sets a handler of the method

type ReqData

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

Jump to

Keyboard shortcuts

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