Documentation ¶
Index ¶
- Constants
- func IsoTimeToRippleTime(isoTime string) (int64, error)
- func RippleTimeToISOTime(rippleTime int64) string
- func RippleTimeToUnixTime(rippleTime int64) int64
- func StreamResponseType(streamType string) string
- func UnixTimeToRippleTime(unixTime int64) int64
- type BaseRequest
- type BaseResponse
- type Client
- func (c *Client) Close() error
- func (c *Client) NewConnection() (*websocket.Conn, error)
- func (c *Client) NextID() string
- func (c *Client) Ping(message []byte) error
- func (c *Client) Reconnect() error
- func (c *Client) Request(req BaseRequest) (BaseResponse, error)
- func (c *Client) Subscribe(streams []string) (BaseResponse, error)
- func (c *Client) Subscriptions() []string
- func (c *Client) Unsubscribe(streams []string) (BaseResponse, error)
- type ClientConfig
- type Network
Constants ¶
const ( StreamTypeLedger = "ledger" StreamTypeTransaction = "transactions" StreamTypeTransactionsProposed = "transactions_proposed" StreamTypeValidations = "validations" StreamTypeManifests = "manifests" StreamTypePeerStatus = "peer_status" StreamTypeConsensus = "consensus" StreamTypePathFind = "path_find" StreamTypeServer = "server" StreamTypeResponse = "response" )
XRPL stream types as defined in rippled:
- https://github.com/XRPLF/xrpl.js/blob/main/packages/xrpl/src/models/common/index.ts#L36
- https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Subscribe.cpp#L127
const RIPPLE_EPOCH_DIFF int64 = 946684800
Seconds since UNIX Epoch to Ripple Epoch (2000-01-01T00:00 UTC) https://xrpl.org/docs/references/protocol/data-types/basic-data-types#specifying-time
const XAHAU_NATIVE_ASSET = "XAH"
const XRPL_NATIVE_ASSET = "XRP"
Variables ¶
This section is empty.
Functions ¶
func IsoTimeToRippleTime ¶ added in v0.2.5
Convert an ISO8601 timestamp to a Ripple timestamp.
func RippleTimeToISOTime ¶ added in v0.2.5
Convert a Ripple timestamp to an ISO8601 time.
func RippleTimeToUnixTime ¶ added in v0.2.5
Convert a Ripple timestamp to a unix timestamp.
func StreamResponseType ¶
StreamResponseType returns a string denoting 'type' property present in the requested StreamType's response. It returns the empty string if there's no match for the requested StreamType.
func UnixTimeToRippleTime ¶ added in v0.2.5
Convert a unix timestamp to a Ripple timestamp.
Types ¶
type BaseRequest ¶
type BaseRequest map[string]interface{}
BaseRequest is a map of keys and values. Values are usually strings, but may be complex interface{} type
type BaseResponse ¶
type BaseResponse map[string]interface{}
BaseResponse is a map of keys and values. Values may be complex interface{} type
type Client ¶
type Client struct { StreamLedger chan []byte StreamTransaction chan []byte StreamValidation chan []byte StreamManifest chan []byte StreamPeerStatus chan []byte StreamConsensus chan []byte StreamPathFind chan []byte StreamServer chan []byte StreamDefault chan []byte StreamSubscriptions map[string]bool // contains filtered or unexported fields }
func NewClient ¶
func NewClient(config ClientConfig) *Client
func (*Client) NewConnection ¶ added in v0.2.0
func (*Client) NextID ¶
Returns incremental ID that may be used as request ID for websocket requests
func (*Client) Request ¶
func (c *Client) Request(req BaseRequest) (BaseResponse, error)
Send a websocket request. This method takes a BaseRequest object and automatically adds incremental request ID to it.
Example usage:
req := BaseRequest{ "command": "account_info", "account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn", "ledger_index": "current", } err := client.Request(req, func(){})
func (*Client) Subscriptions ¶ added in v0.2.0
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(streams []string) (BaseResponse, error)
type ClientConfig ¶
type ClientConfig struct { URL string Authorization string Certificate string FeeCushion uint32 Key string MaxFeeXRP uint64 Passphrase byte Proxy byte ProxyAuthorization byte ReadTimeout time.Duration // Default is 60 seconds WriteTimeout time.Duration // Default is 60 seconds HeartbeatInterval time.Duration // Default is 5 seconds QueueCapacity int // Default is 128 }
func (*ClientConfig) Validate ¶
func (config *ClientConfig) Validate() error