rpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PendingBlockFlag  = "pending"
	LatestBlockFlag   = "latest"
	EarliestBlockFlag = "earliest"
)
View Source
const (
	PendingBlockNumber  = BlockNumber(-3)
	LatestBlockNumber   = BlockNumber(-2)
	EarliestBlockNumber = BlockNumber(-1)
)

Variables

View Source
var (
	ErrStateNotFound = errors.New("given root and slot not found in storage")
)

Functions

func NewInternalError

func NewInternalError(msg string) *internalError

func NewInvalidParamsError

func NewInvalidParamsError(msg string) *invalidParamsError

func NewInvalidRequestError

func NewInvalidRequestError(msg string) *invalidRequestError

func NewMethodNotFoundError

func NewMethodNotFoundError(method string) *methodNotFoundError

func NewSubscriptionNotFoundError

func NewSubscriptionNotFoundError(method string) *subscriptionNotFoundError

Types

type BlockNumber

type BlockNumber int64

func CreateBlockNumberPointer

func CreateBlockNumberPointer(str string) (*BlockNumber, error)

func StringToBlockNumber

func StringToBlockNumber(str string) (BlockNumber, error)

func (*BlockNumber) UnmarshalJSON

func (b *BlockNumber) UnmarshalJSON(buffer []byte) error

UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called

type BlockNumberOrHash

type BlockNumberOrHash struct {
	BlockNumber *BlockNumber `json:"blockNumber,omitempty"`
	BlockHash   *types.Hash  `json:"blockHash,omitempty"`
}

func (*BlockNumberOrHash) UnmarshalJSON

func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error

UnmarshalJSON will try to extract the filter's data. Here are the possible input formats :

1 - "latest", "pending" or "earliest" - self-explaining keywords 2 - "0x2" - block number #2 (EIP-1898 backward compatible) 3 - {blockNumber: "0x2"} - EIP-1898 compliant block number #2 4 - {blockHash: "0xe0e..."} - EIP-1898 compliant block hash 0xe0e...

type Error

type Error interface {
	Error() string
	ErrorCode() int
}

type GetBalanceParams

type GetBalanceParams struct {
	Address types.Address
	Number  *BlockNumber
}

func (*GetBalanceParams) Unmarshal

func (gp *GetBalanceParams) Unmarshal(params ...any) error

type Request

type Request struct {
	Version string `json:"jsonrpc,omitempty"`
	Method  string `json:"method"`
	Params  []any  `json:"params"`
	ID      any    `json:"id"`
}

type Response

type Response struct {
	ID      any    `json:"id"`
	Version string `json:"jsonrpc"`
	Result  any    `json:"result"`
}

type RpcFunc

type RpcFunc func(method string, params ...any) any

type RpcServer

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

func NewRpcServer

func NewRpcServer(logger hclog.Logger,
	blockchain *blockchain.Blockchain,
	addr, port string) *RpcServer

func (*RpcServer) GetBalance

func (s *RpcServer) GetBalance(method string, params ...any) any

not support "earliest" and "pending"

func (*RpcServer) GetBlockNumber

func (s *RpcServer) GetBlockNumber(method string, params ...any) any

func (*RpcServer) Start

func (s *RpcServer) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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