Documentation ¶
Index ¶
- Constants
- Variables
- type BestNodeClientProvider
- type BitsharesAPI
- type ClientProvider
- type ErrorFunc
- type LatencyTester
- type NodeStats
- type NotifyFunc
- type RPCCall
- type RPCClient
- type ResponseError
- type ResponseErrorContext
- type ResponseErrorData
- type ResponseErrorStack
- type SimpleClientProvider
- type WebsocketClient
Constants ¶
const ( InvalidApiID = -1 AssetsListAll = -1 AssetsMaxBatchSize = 100 GetCallOrdersLimit = 100 GetLimitOrdersLimit = 100 GetSettleOrdersLimit = 100 GetTradeHistoryLimit = 100 GetAccountHistoryLimit = 100 )
Variables ¶
var ( DialerTimeout = time.Duration(5 * time.Second) ReadWriteTimeout = time.Duration(10 * time.Second) ErrShutdown = errors.New("connection is shut down") )
var (
//LoopSeconds = time for one pass to calc dynamic delay
LoopSeconds = 60
)
Functions ¶
This section is empty.
Types ¶
type BestNodeClientProvider ¶
type BestNodeClientProvider struct { WebsocketClient // contains filtered or unexported fields }
func (*BestNodeClientProvider) CallAPI ¶
func (p *BestNodeClientProvider) CallAPI(apiID int, method string, args ...interface{}) (interface{}, error)
func (*BestNodeClientProvider) Close ¶
func (p *BestNodeClientProvider) Close() error
type BitsharesAPI ¶
type BitsharesAPI interface { //Common functions //Websocket API functions //Wallet API functions }
func New ¶
func New(wsEndpointURL, rpcEndpointURL string) BitsharesAPI
New creates a new BitsharesAPI interface. wsEndpointURL: Is a mandatory websocket node URL. rpcEndpointURL: Is an optional RPC endpoint to your local `cli_wallet`. The use of wallet functions without this argument will throw an error. If you do not use wallet API, provide an empty string.
func NewWithAutoEndpoint ¶
func NewWithAutoEndpoint(startupEndpointURL, rpcEndpointURL string) (BitsharesAPI, error)
NewWithAutoEndpoint creates a new BitsharesAPI interface with automatic node latency checking. It's best to use this API instance type for a long API lifecycle because the latency tester takes time to unleash its magic. startupEndpointURL: Iss a mandatory websocket node URL to startup the latency tester quickly. rpcEndpointURL: Is an optional RPC endpoint to your local `cli_wallet`. The use of wallet functions without this argument will throw an error. If you do not use wallet API, provide an empty string.
type ClientProvider ¶
type ClientProvider interface { OnError(fn ErrorFunc) Connect() error OnNotify(subscriberID int, fn NotifyFunc) error CallAPI(apiID int, method string, args ...interface{}) (interface{}, error) Close() error }
func NewBestNodeClientProvider ¶
func NewBestNodeClientProvider(endpointURL string, api BitsharesAPI) (ClientProvider, error)
func NewSimpleClientProvider ¶
func NewSimpleClientProvider(endpointURL string, api BitsharesAPI) ClientProvider
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{} }
func NewLatencyTester ¶
func NewLatencyTester(fallbackURL string) (LatencyTester, error)
func NewLatencyTesterWithContext ¶
func NewLatencyTesterWithContext(ctx context.Context, fallbackURL string) (LatencyTester, error)
type NodeStats ¶
type NodeStats struct {
// contains filtered or unexported fields
}
NodeStats holds stat data for each endpoint
func NewNodeStats ¶
NewNodeStats creates a new stat object
type NotifyFunc ¶
type NotifyFunc func(msg interface{}) error
type RPCClient ¶
type RPCClient interface { CallAPI(method string, args ...interface{}) (interface{}, error) Close() error Connect() error }
func NewRPCClient ¶
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
type ResponseErrorContext ¶
type ResponseErrorData ¶
type ResponseErrorData struct { Code int `json:"code"` Name string `json:"name"` Message string `json:"message"` Stack []ResponseErrorStack `json:"stack"` }
type ResponseErrorStack ¶
type ResponseErrorStack struct { Context ResponseErrorContext `json:"context"` Format string `json:"format"` Data interface{} `json:"data"` }
type SimpleClientProvider ¶
type SimpleClientProvider struct { WebsocketClient // contains filtered or unexported fields }
type WebsocketClient ¶
type WebsocketClient interface { IsConnected() bool OnError(fn ErrorFunc) OnNotify(subscriberID int, fn NotifyFunc) error Call(method string, args []interface{}) (*RPCCall, error) CallAPI(apiID int, method string, args ...interface{}) (interface{}, error) Close() error Connect() error }
func NewWebsocketClient ¶
func NewWebsocketClient(endpointURL string) WebsocketClient