api

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DialerTimeout    = time.Duration(5 * time.Second)
	ReadWriteTimeout = time.Duration(10 * time.Second)
	ErrShutdown      = errors.New("connection is shut down")
)
View Source
var (
	//LoopSeconds = time for one pass to calc dynamic delay
	LoopSeconds = 60
)

Functions

This section is empty.

Types

type BlockAppliedCallback added in v0.6.2

type BlockAppliedCallback func(blockID string) error

type ErrorFunc

type ErrorFunc func(error)

type LatencyTester

type LatencyTester interface {
	Start()
	Close() error
	String() string
	AddEndpoint(ep string)
	OnTopNodeChanged(fn func(string) error)
	TopNodeEndpoint() string
	TopNodeClient() WebsocketClient
	Done() <-chan struct{}
}

LatencyTester provides reliability and speed testing through a collection of node endpoints and maintains the best connection.

func NewLatencyTester

func NewLatencyTester(fallbackURL string) (LatencyTester, error)

NewLatencyTester creates a new LatencyTester and allows you to always be connected to the best node.

func NewLatencyTesterWithContext

func NewLatencyTesterWithContext(ctx context.Context, fallbackURL string) (LatencyTester, error)

NewLatencyTesterWithContext - like NewLatencyTester but cancelable.

type NodeStats

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

NodeStats holds stat data for each endpoint

func NewNodeStats

func NewNodeStats(wsRPCEndpoint string) *NodeStats

NewNodeStats creates a new stat object

func (*NodeStats) Equals

func (p *NodeStats) Equals(n *NodeStats) bool

Equals checks if the NodeStats belong to the same endpoint.

func (*NodeStats) Latency

func (p *NodeStats) Latency() time.Duration

Latency returns the nodes latency

func (*NodeStats) Score

func (p *NodeStats) Score() int64

Score returns reliability score for each node. The less the better.

func (*NodeStats) String

func (p *NodeStats) String() string

String returns the stats string representation

type RPCCall

type RPCCall struct {
	Method  string
	Request rpcRequest
	Reply   *json.RawMessage
	Error   error
	Done    chan *RPCCall
}

ffjson: skip

type RPCClient

type RPCClient interface {
	CallAPI(method string, args ...interface{}) (*json.RawMessage, error)
	Close() error
	Connect() error
}

RPCClient allows you to access wallett functions

func NewRPCClient

func NewRPCClient(rpcEndpointURL string) RPCClient

NewRPCClient creates a new RPC Client

type ResponseError

type ResponseError struct {
	Code    int               `json:"code"`
	Message string            `json:"message"`
	Data    ResponseErrorData `json:"data"`
}

func (ResponseError) Error

func (p ResponseError) Error() string

func (*ResponseError) MarshalJSON added in v0.6.2

func (j *ResponseError) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*ResponseError) MarshalJSONBuf added in v0.6.2

func (j *ResponseError) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*ResponseError) UnmarshalJSON added in v0.6.2

func (j *ResponseError) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*ResponseError) UnmarshalJSONFFLexer added in v0.6.2

func (j *ResponseError) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type ResponseErrorContext

type ResponseErrorContext struct {
	Level      string `json:"level"`
	File       string `json:"file"`
	Line       int    `json:"line"`
	Method     string `json:"method"`
	Hostname   string `json:"hostname"`
	ThreadName string `json:"thread_name"`
	Timestamp  string `json:"timestamp"`
}

func (*ResponseErrorContext) MarshalJSON added in v0.6.2

func (j *ResponseErrorContext) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*ResponseErrorContext) MarshalJSONBuf added in v0.6.2

func (j *ResponseErrorContext) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*ResponseErrorContext) UnmarshalJSON added in v0.6.2

func (j *ResponseErrorContext) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*ResponseErrorContext) UnmarshalJSONFFLexer added in v0.6.2

func (j *ResponseErrorContext) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type ResponseErrorData

type ResponseErrorData struct {
	Code    int                  `json:"code"`
	Name    string               `json:"name"`
	Message string               `json:"message"`
	Stack   []ResponseErrorStack `json:"stack"`
}

func (*ResponseErrorData) MarshalJSON added in v0.6.2

func (j *ResponseErrorData) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*ResponseErrorData) MarshalJSONBuf added in v0.6.2

func (j *ResponseErrorData) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*ResponseErrorData) UnmarshalJSON added in v0.6.2

func (j *ResponseErrorData) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*ResponseErrorData) UnmarshalJSONFFLexer added in v0.6.2

func (j *ResponseErrorData) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type ResponseErrorStack

type ResponseErrorStack struct {
	Context ResponseErrorContext `json:"context"`
	Format  string               `json:"format"`
	Data    interface{}          `json:"data"`
}

func (*ResponseErrorStack) MarshalJSON added in v0.6.2

func (j *ResponseErrorStack) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*ResponseErrorStack) MarshalJSONBuf added in v0.6.2

func (j *ResponseErrorStack) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*ResponseErrorStack) UnmarshalJSON added in v0.6.2

func (j *ResponseErrorStack) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*ResponseErrorStack) UnmarshalJSONFFLexer added in v0.6.2

func (j *ResponseErrorStack) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type SubscribeCallback added in v0.6.2

type SubscribeCallback func(msg interface{}) error

type WebsocketClient

type WebsocketClient interface {
	IsConnected() bool
	OnError(fn ErrorFunc)
	Subscribe(apiID int, method string, fn SubscribeCallback, args ...interface{}) (*json.RawMessage, error)
	Call(method string, args []interface{}) (*RPCCall, error)
	CallAPI(apiID int, method string, args ...interface{}) (*json.RawMessage, error)
	Close() error
	Connect() error
}

func NewWebsocketClient

func NewWebsocketClient(endpointURL string) WebsocketClient

Jump to

Keyboard shortcuts

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