web3

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The index in heap which is indicating the element is not in the heap
	NoIndexInHeap = -1
)

Variables

View Source
var (
	ErrFilterNotFound                   = errors.New("filter not found")
	ErrWSFilterDoesNotSupportGetChanges = errors.New("web socket Filter doesn't support to return a batch of the changes")
	ErrNoWSConnection                   = errors.New("no websocket connection")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Store                    JSONRPCStore
	Addr                     *net.TCPAddr
	NetworkID                uint64
	NetworkName              string
	Version                  string
	AccessControlAllowOrigin []string
}

type Dispatcher

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

Dispatcher handles all json rpc requests by delegating the execution flow to the corresponding service

func (*Dispatcher) Handle

func (d *Dispatcher) Handle(reqBody []byte) ([]byte, error)

func (*Dispatcher) HandleWs

func (d *Dispatcher) HandleWs(reqBody []byte, conn wsConn) ([]byte, error)

func (*Dispatcher) RemoveFilterByWs

func (d *Dispatcher) RemoveFilterByWs(conn wsConn)

type Edge

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

Edge is the edge jsonrpc endpoint

func (*Edge) GetFilterChanges

func (e *Edge) GetFilterChanges(id string) (interface{}, error)

GetFilterChanges is a polling method for a filter, which returns an array of logs which occurred since last poll.

func (*Edge) NetworkId

func (e *Edge) NetworkId() (interface{}, error)

NetworkId returns the network id of the client

func (*Edge) SendRawTelegram

func (e *Edge) SendRawTelegram(buf argBytes) (interface{}, error)

SendRawTelegram sends a raw telegram

func (*Edge) UninstallFilter

func (e *Edge) UninstallFilter(id string) (bool, error)

UninstallFilter uninstalls a filter with given ID

func (*Edge) Unsubscribe

func (e *Edge) Unsubscribe(id string) (bool, error)

Unsubscribe uninstalls a filter in a websocket

type ErrorResponse

type ErrorResponse struct {
	JSONRPC string       `json:"jsonrpc"`
	ID      interface{}  `json:"id,omitempty"`
	Error   *ObjectError `json:"error"`
}

ErrorResponse is a jsonrpc error response

func (*ErrorResponse) Bytes

func (e *ErrorResponse) Bytes() ([]byte, error)

Bytes return the serialized response

func (*ErrorResponse) Data

func (e *ErrorResponse) Data() json.RawMessage

Data returns ObjectError

func (*ErrorResponse) GetID

func (e *ErrorResponse) GetID() interface{}

GetID returns error response id

type GetResponse

type GetResponse struct {
	Name      string `json:"name"`
	NetworkID uint64 `json:"networkID"`
	Version   string `json:"version"`
}

type JSONRPC

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

JSONRPC is an API consensus

func NewJSONRPC

func NewJSONRPC(logger hclog.Logger, config *Config) (*JSONRPC, error)

NewJSONRPC returns the JSONRPC http server

type JSONRPCStore

type JSONRPCStore interface {
	// contains filtered or unexported methods
}

JSONRPCStore defines all the methods required by all the JSON RPC endpoints

type NodeFilterManager

type NodeFilterManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NodeFilterManager manages all running node filters

func NewNodeFilterManager

func NewNodeFilterManager(logger hclog.Logger, store nodeFilterManagerStore) *NodeFilterManager

func (*NodeFilterManager) Close

func (f *NodeFilterManager) Close()

Close closed closeCh so that terminate worker

func (*NodeFilterManager) Exists

func (f *NodeFilterManager) Exists(id string) bool

Exists checks the filter with given ID exists

func (*NodeFilterManager) GetFilterChanges

func (f *NodeFilterManager) GetFilterChanges(id string) (interface{}, error)

GetFilterChanges returns the updates of the filter with given ID in string, and refreshes the timeout on the filter

func (*NodeFilterManager) NewNodeFilter

func (f *NodeFilterManager) NewNodeFilter(nodeQuery *NodeQuery, ws wsConn) string

NewRtcFilter adds new RtcFilter

func (*NodeFilterManager) RemoveFilterByWs

func (f *NodeFilterManager) RemoveFilterByWs(ws wsConn)

RemoveFilterByWs removes the filter with given WS [Thread safe]

func (*NodeFilterManager) Run

func (f *NodeFilterManager) Run()

Run starts worker process to handle events

func (*NodeFilterManager) Uninstall

func (f *NodeFilterManager) Uninstall(id string) bool

Uninstall removes the filter with given ID from list

type NodeQuery

type NodeQuery struct {
	Name    string `json:"name"`
	Tag     string `json:"tag"`
	Id      string `json:"id"`
	Version string `json:"version"`
}

NodeQuery is a query to filter node

func DecodeNodeQueryFromInterface

func DecodeNodeQueryFromInterface(i interface{}) (*NodeQuery, error)

func (*NodeQuery) Match

func (q *NodeQuery) Match(rm *application.Application) bool

type ObjectError

type ObjectError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

ObjectError is a jsonrpc error

func (*ObjectError) Error

func (e *ObjectError) Error() string

Error implements error interface

type Request

type Request struct {
	ID     interface{}     `json:"id"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

Request is a jsonrpc request

type Response

type Response interface {
	GetID() interface{}
	Data() json.RawMessage
	Bytes() ([]byte, error)
}

Response is a jsonrpc response interface

func NewRPCErrorResponse

func NewRPCErrorResponse(id interface{}, errCode int, err string, jsonrpcver string) Response

NewRPCErrorResponse is used to create a custom error response

func NewRPCResponse

func NewRPCResponse(id interface{}, jsonrpcver string, reply []byte, err jsonrpc.Error) Response

NewRPCResponse returns Success/Error response object

type SuccessResponse

type SuccessResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   *ObjectError    `json:"error,omitempty"`
}

SuccessResponse is a jsonrpc success response

func (*SuccessResponse) Bytes

func (s *SuccessResponse) Bytes() ([]byte, error)

Bytes return the serialized response

func (*SuccessResponse) Data

func (s *SuccessResponse) Data() json.RawMessage

Data returns the result

func (*SuccessResponse) GetID

func (s *SuccessResponse) GetID() interface{}

GetID returns success response id

Jump to

Keyboard shortcuts

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