websockets

package
v0.0.0-...-cad4448 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: ISC Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfoCommand

type AccountInfoCommand struct {
	*Command
	Account     data.Account       `json:"account"`
	SignerLists bool               `json:"signer_lists"`
	Result      *AccountInfoResult `json:"result,omitempty"`
}

type AccountInfoResult

type AccountInfoResult struct {
	LedgerSequence uint32           `json:"ledger_current_index"`
	AccountData    data.AccountRoot `json:"account_data"`
}

type AccountLinesCommand

type AccountLinesCommand struct {
	*Command
	Account     data.Account        `json:"account"`
	Limit       uint32              `json:"limit"`
	LedgerIndex interface{}         `json:"ledger_index,omitempty"`
	Marker      *data.Hash256       `json:"marker,omitempty"`
	Result      *AccountLinesResult `json:"result,omitempty"`
}

type AccountLinesResult

type AccountLinesResult struct {
	LedgerSequence *uint32               `json:"ledger_index"`
	Account        data.Account          `json:"account"`
	Marker         *data.Hash256         `json:"marker"`
	Lines          data.AccountLineSlice `json:"lines"`
}

type AccountOffersCommand

type AccountOffersCommand struct {
	*Command
	Account     data.Account         `json:"account"`
	Limit       uint32               `json:"limit"`
	LedgerIndex interface{}          `json:"ledger_index,omitempty"`
	Marker      *data.Hash256        `json:"marker,omitempty"`
	Result      *AccountOffersResult `json:"result,omitempty"`
}

type AccountOffersResult

type AccountOffersResult struct {
	LedgerSequence *uint32                `json:"ledger_index"`
	Account        data.Account           `json:"account"`
	Marker         *data.Hash256          `json:"marker"`
	Offers         data.AccountOfferSlice `json:"offers"`
}

type AccountTxCommand

type AccountTxCommand struct {
	*Command
	Account   data.Account           `json:"account"`
	MinLedger int64                  `json:"ledger_index_min"`
	MaxLedger int64                  `json:"ledger_index_max"`
	Binary    bool                   `json:"binary,omitempty"`
	Forward   bool                   `json:"forward,omitempty"`
	Limit     int                    `json:"limit,omitempty"`
	Marker    map[string]interface{} `json:"marker,omitempty"`
	Result    *AccountTxResult       `json:"result,omitempty"`
}

type AccountTxResult

type AccountTxResult struct {
	Marker       map[string]interface{} `json:"marker,omitempty"`
	Transactions data.TransactionSlice  `json:"transactions,omitempty"`
}

type BinaryLedgerData

type BinaryLedgerData struct {
	Data  string `json:"data"`
	Index string `json:"index"`
}

type BinaryLedgerDataCommand

type BinaryLedgerDataCommand struct {
	*Command
	Ledger interface{}             `json:"ledger"`
	Binary bool                    `json:"binary"`
	Marker *data.Hash256           `json:"marker,omitempty"`
	Result *BinaryLedgerDataResult `json:"result,omitempty"`
}

type BinaryLedgerDataResult

type BinaryLedgerDataResult struct {
	LedgerSequence uint32             `json:"ledger_index"`
	Hash           data.Hash256       `json:"ledger_hash"`
	Marker         *data.Hash256      `json:"marker"`
	State          []BinaryLedgerData `json:"state"`
}

type BookOffersCommand

type BookOffersCommand struct {
	*Command
	LedgerIndex interface{}  `json:"ledger_index,omitempty"`
	Taker       data.Account `json:"taker"`
	TakerPays   data.Asset   `json:"taker_pays"`
	TakerGets   data.Asset   `json:"taker_gets"`
	Limit       uint32       `json:"limit"`
	Result      *BookOffersResult
}

type BookOffersResult

type BookOffersResult struct {
	LedgerSequence uint32                `json:"ledger_index"`
	Offers         []data.OrderBookOffer `json:"offers"`
}

type Command

type Command struct {
	*CommandError
	Id     uint64        `json:"id"`
	Name   string        `json:"command"`
	Type   string        `json:"type,omitempty"`
	Status string        `json:"status,omitempty"`
	Ready  chan struct{} `json:"-"`
}

func (*Command) Done

func (c *Command) Done()

func (*Command) Fail

func (c *Command) Fail(message string)

func (*Command) IncrementId

func (c *Command) IncrementId()

type CommandError

type CommandError struct {
	Name    string `json:"error"`
	Code    int    `json:"error_code"`
	Message string `json:"error_message"`
}

func (*CommandError) Error

func (e *CommandError) Error() string

type FeeCommand

type FeeCommand struct {
	*Command
	Result *FeeResult
}

type FeeResult

type FeeResult struct {
	CurrentLedgerSize uint32 `json:"current_ledger_size,string"`
	CurrentQueueSize  uint32 `json:"current_queue_size,string"`
	Drops             struct {
		BaseFee       data.Value `json:"base_fee"`
		MedianFee     data.Value `json:"median_fee"`
		MinimumFee    data.Value `json:"minimum_fee"`
		OpenLedgerFee data.Value `json:"open_ledger_fee"`
	} `json:"drops"`
	ExpectedLedgerSize uint32 `json:"expected_ledger_size,string"`
	Levels             struct {
		MedianLevel     data.Value `json:"median_level"`
		MinimumLevel    data.Value `json:"minimum_level"`
		OpenLedgerLevel data.Value `json:"open_ledger_level"`
		ReferenceLevel  data.Value `json:"reference_level"`
	} `json:"levels"`
	MaxQueueSize uint32 `json:"max_queue_size,string"`
	Status       string `json:"status"`
}

type LedgerCommand

type LedgerCommand struct {
	*Command
	LedgerIndex  interface{}   `json:"ledger_index"`
	Accounts     bool          `json:"accounts"`
	Transactions bool          `json:"transactions"`
	Expand       bool          `json:"expand"`
	Result       *LedgerResult `json:"result,omitempty"`
}

type LedgerDataCommand

type LedgerDataCommand struct {
	*Command
	Ledger interface{}       `json:"ledger"`
	Marker *data.Hash256     `json:"marker,omitempty"`
	Result *LedgerDataResult `json:"result,omitempty"`
}

type LedgerDataResult

type LedgerDataResult struct {
	LedgerSequence uint32                `json:"ledger_index"`
	Hash           data.Hash256          `json:"ledger_hash"`
	Marker         *data.Hash256         `json:"marker"`
	State          data.LedgerEntrySlice `json:"state"`
}

type LedgerHeaderCommand

type LedgerHeaderCommand struct {
	*Command
	Ledger interface{} `json:"ledger"`
	Result *LedgerHeaderResult
}

type LedgerHeaderResult

type LedgerHeaderResult struct {
	Ledger         data.Ledger
	LedgerSequence uint32              `json:"ledger_index"`
	Hash           *data.Hash256       `json:"ledger_hash,omitempty"`
	LedgerData     data.VariableLength `json:"ledger_data"`
}

type LedgerResult

type LedgerResult struct {
	Ledger data.Ledger
}

type LedgerStreamMsg

type LedgerStreamMsg struct {
	FeeBase          uint64          `json:"fee_base"`
	FeeRef           uint64          `json:"fee_ref"`
	LedgerSequence   uint32          `json:"ledger_index"`
	LedgerHash       data.Hash256    `json:"ledger_hash"`
	LedgerTime       data.RippleTime `json:"ledger_time"`
	ReserveBase      uint64          `json:"reserve_base"`
	ReserveIncrement uint64          `json:"reserve_inc"`
	ValidatedLedgers string          `json:"validated_ledgers"`
	TxnCount         uint32          `json:"txn_count"` // Only streamed, not in the subscribe result.
}

Fields from subscribed ledger stream messages

type OrderBookSubscription

type OrderBookSubscription struct {
	TakerGets data.Asset `json:"taker_gets"`
	TakerPays data.Asset `json:"taker_pays"`
	Snapshot  bool       `json:"snapshot"`
	Both      bool       `json:"both"`
}

type PathFindAlternative

type PathFindAlternative struct {
	// TODO paths_computed
	SourceAmount data.Amount `json:"source_amount"`
}

type PathFindCreateCommand

type PathFindCreateCommand struct {
	*Command
	Subcommand         string            `json:"subcommand"`
	SourceAccount      data.Account      `json:"source_account"`
	DestinationAccount data.Account      `json:"destination_account"`
	DestinationAmount  data.Amount       `json:"destination_amount"`
	SendMax            *data.Amount      `json:"send_max,omitempty"`
	SourceCurrencies   *[]SourceCurrency `json:"source_currencies,omitempty"`

	// All commands have Result in their struct?
	Result *PathFindCreateResult
}

https://ripple.com/build/rippled-apis/#path-find

{
    "id": 8,
    "command": "path_find",
    "subcommand": "create",
    "source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
    "destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
    "destination_amount": {
        "value": "0.001",
        "currency": "USD",
        "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
    }
}

type PathFindCreateResult

type PathFindCreateResult struct {
	SourceAccount      data.Account `json:"source_account"`
	DestinationAccount data.Account `json:"destination_account"`
	DestinationAmount  data.Amount  `json:"destination_amount"`
	// TODO
	Alternatives []PathFindAlternative
}

type Remote

type Remote struct {
	Incoming chan interface{}
	// contains filtered or unexported fields
}

func NewRemote

func NewRemote(endpoint string) (*Remote, error)

NewRemote returns a new remote session connected to the specified server endpoint URI. To close the connection, use Close().

func (*Remote) AccountInfo

func (r *Remote) AccountInfo(a data.Account) (*AccountInfoResult, error)

Synchronously requests account info

func (*Remote) AccountLines

func (r *Remote) AccountLines(account data.Account, ledgerIndex interface{}) (*AccountLinesResult, error)

Synchronously requests account line info

func (*Remote) AccountOffers

func (r *Remote) AccountOffers(account data.Account, ledgerIndex interface{}) (*AccountOffersResult, error)

Synchronously requests account offers

func (*Remote) AccountTx

func (r *Remote) AccountTx(account data.Account, pageSize int, minLedger, maxLedger int64) chan *data.TransactionWithMetaData

Retrieve all transactions for an account via https://ripple.com/build/rippled-apis/#account-tx. Will call `account_tx` multiple times, if a marker is returned. Transactions are returned asynchonously to the channel returned by this function.

Use minLedger -1 for the earliest ledger available. Use maxLedger -1 for the most recent validated ledger.

func (*Remote) BookOffers

func (r *Remote) BookOffers(taker data.Account, ledgerIndex interface{}, pays, gets data.Asset) (*BookOffersResult, error)

func (*Remote) Close

func (r *Remote) Close()

Close shuts down the Remote session and blocks until all internal goroutines have been cleaned up. Any commands that are pending a response will return with an error.

func (*Remote) Fee

func (r *Remote) Fee() (*FeeResult, error)

func (*Remote) Ledger

func (r *Remote) Ledger(ledger interface{}, transactions bool) (*LedgerResult, error)

Synchronously gets a single ledger

func (*Remote) LedgerData

func (r *Remote) LedgerData(ledger interface{}, marker *data.Hash256) (*LedgerDataResult, error)

Synchronously gets ledger entries

func (*Remote) LedgerHeader

func (r *Remote) LedgerHeader(ledger interface{}) (*LedgerHeaderResult, error)

func (*Remote) PathFindCreate

func (r *Remote) PathFindCreate(src, dest data.Account, amt data.Amount, sendMax *data.Amount, sourceCurrencies *[]SourceCurrency) (*PathFindCreateResult, error)

func (*Remote) RipplePathFind

func (r *Remote) RipplePathFind(src, dest data.Account, amount data.Amount, srcCurr *[]data.Currency) (*RipplePathFindResult, error)

Synchronously requests paths

func (*Remote) StreamLedgerData

func (r *Remote) StreamLedgerData(ledger interface{}) chan data.LedgerEntrySlice

Asynchronously retrieve all data for a ledger using the binary form

func (*Remote) Submit

func (r *Remote) Submit(tx data.Transaction) (*SubmitResult, error)

Synchronously submit a single transaction

func (*Remote) SubmitBatch

func (r *Remote) SubmitBatch(txs []data.Transaction) ([]*SubmitResult, error)

Synchronously submit multiple transactions

func (*Remote) SubmitMultiSigned

func (r *Remote) SubmitMultiSigned(tx data.Transaction) (*SubmitResult, error)

Synchronously submit a single transaction

func (*Remote) Subscribe

func (r *Remote) Subscribe(ledger, transactions, transactionsProposed, server bool) (*SubscribeResult, error)

Synchronously subscribe to streams and receive a confirmation message Streams are recived asynchronously over the Incoming channel

func (*Remote) SubscribeOrderBooks

func (r *Remote) SubscribeOrderBooks(books []OrderBookSubscription) (*SubscribeResult, error)

func (*Remote) Tx

func (r *Remote) Tx(hash data.Hash256) (*TxResult, error)

Synchronously get a single transaction

type RipplePathFindCommand

type RipplePathFindCommand struct {
	*Command
	SrcAccount    data.Account          `json:"source_account"`
	SrcCurrencies *[]data.Currency      `json:"source_currencies,omitempty"`
	DestAccount   data.Account          `json:"destination_account"`
	DestAmount    data.Amount           `json:"destination_amount"`
	Result        *RipplePathFindResult `json:"result,omitempty"`
}

type RipplePathFindResult

type RipplePathFindResult struct {
	Alternatives []struct {
		SrcAmount      data.Amount  `json:"source_amount"`
		PathsComputed  data.PathSet `json:"paths_computed,omitempty"`
		PathsCanonical data.PathSet `json:"paths_canonical,omitempty"`
	}
	DestAccount    data.Account    `json:"destination_account"`
	DestCurrencies []data.Currency `json:"destination_currencies"`
}

type ServerStreamMsg

type ServerStreamMsg struct {
	Status                  string `json:"server_status"`
	BaseFee                 uint64 `json:"base_fee"`
	LoadBase                uint64 `json:"load_base"`
	LoadFactor              uint64 `json:"load_factor"`
	LoadFactorFeeEscalation uint64 `json:"load_factor_fee_escalation"`
	LoadFactorFeeQueue      uint64 `json:"load_factor_fee_queue"`
	LoadFactorFeeReference  uint64 `json:"load_factor_fee_reference"`
	LoadFactorServer        uint64 `json:"load_factor_server"`
	HostID                  string `json:"hostid"`
}

Fields from subscribed server status stream messages

func (*ServerStreamMsg) TransactionCost

func (s *ServerStreamMsg) TransactionCost() uint64

type SourceCurrency

type SourceCurrency struct {
	Currency string `json:"currency"`
}

type SubmitCommand

type SubmitCommand struct {
	*Command
	TxBlob string        `json:"tx_blob"`
	Result *SubmitResult `json:"result,omitempty"`
}

type SubmitMultiSignedCommand

type SubmitMultiSignedCommand struct {
	*Command
	TxJson data.Transaction `json:"tx_json"`
	Result *SubmitResult    `json:"result,omitempty"`
}

type SubmitResult

type SubmitResult struct {
	EngineResult        data.TransactionResult `json:"engine_result"`
	EngineResultCode    int                    `json:"engine_result_code"`
	EngineResultMessage string                 `json:"engine_result_message"`
	TxBlob              string                 `json:"tx_blob"`
	Tx                  interface{}            `json:"tx_json"`
}

type SubscribeCommand

type SubscribeCommand struct {
	*Command
	Streams []string                `json:"streams"`
	Books   []OrderBookSubscription `json:"books,omitempty"`
	Result  *SubscribeResult        `json:"result,omitempty"`
}

type SubscribeResult

type SubscribeResult struct {
	// Contains one or both of these, depending what streams were subscribed
	*LedgerStreamMsg
	*ServerStreamMsg
	// Contains "bids" and "asks" when "both" is true.
	Asks []data.OrderBookOffer
	Bids []data.OrderBookOffer
	// Contains "offers" when "both" is false.
	Offers []data.OrderBookOffer
}

type Syncer

type Syncer interface {
	Done()
	Fail(message string)
}

type TransactionStreamMsg

type TransactionStreamMsg struct {
	Transaction         data.TransactionWithMetaData `json:"transaction"`
	EngineResult        data.TransactionResult       `json:"engine_result"`
	EngineResultCode    int                          `json:"engine_result_code"`
	EngineResultMessage string                       `json:"engine_result_message"`
	LedgerHash          data.Hash256                 `json:"ledger_hash"`
	LedgerSequence      uint32                       `json:"ledger_index"`
	Status              string
	Validated           bool
}

Fields from subscribed transaction stream messages

func (*TransactionStreamMsg) UnmarshalJSON

func (msg *TransactionStreamMsg) UnmarshalJSON(b []byte) error

type TxCommand

type TxCommand struct {
	*Command
	Transaction data.Hash256 `json:"transaction"`
	Result      *TxResult    `json:"result,omitempty"`
}

type TxResult

type TxResult struct {
	data.TransactionWithMetaData
	Validated bool `json:"validated"`
}

func (*TxResult) UnmarshalJSON

func (txr *TxResult) UnmarshalJSON(b []byte) error

A shim to populate the Validated field before passing control on to TransactionWithMetaData.UnmarshalJSON

Jump to

Keyboard shortcuts

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