Documentation ¶
Index ¶
- type OrderBookGraph
- func (graph *OrderBookGraph) AddOffer(offer xdr.OfferEntry) *OrderBookGraph
- func (graph *OrderBookGraph) Apply() error
- func (graph *OrderBookGraph) Discard()
- func (graph *OrderBookGraph) FindFixedPaths(maxPathLength int, sourceAccountID *xdr.AccountId, sourceAsset xdr.Asset, ...) ([]Path, error)
- func (graph *OrderBookGraph) FindPaths(maxPathLength int, destinationAsset xdr.Asset, destinationAmount xdr.Int64, ...) ([]Path, error)
- func (graph *OrderBookGraph) IsEmpty() bool
- func (graph *OrderBookGraph) Offers() []xdr.OfferEntry
- func (graph *OrderBookGraph) RemoveOffer(offerID xdr.Int64) *OrderBookGraph
- type Path
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderBookGraph ¶
type OrderBookGraph struct {
// contains filtered or unexported fields
}
OrderBookGraph is an in memory graph representation of all the offers in the diamnet ledger
func NewOrderBookGraph ¶
func NewOrderBookGraph() *OrderBookGraph
NewOrderBookGraph constructs a new OrderBookGraph
func (*OrderBookGraph) AddOffer ¶
func (graph *OrderBookGraph) AddOffer(offer xdr.OfferEntry) *OrderBookGraph
AddOffer will queue an operation to add the given offer to the order book in the internal batch. You need to run Apply() to apply all enqueued operations.
func (*OrderBookGraph) Apply ¶
func (graph *OrderBookGraph) Apply() error
Apply will attempt to apply all the updates in the internal batch to the order book. When Apply is successful, a new empty, instance of internal batch will be created.
func (*OrderBookGraph) Discard ¶
func (graph *OrderBookGraph) Discard()
Discard removes all operations which have been queued but not yet applied to the OrderBookGraph
func (*OrderBookGraph) FindFixedPaths ¶
func (graph *OrderBookGraph) FindFixedPaths( maxPathLength int, sourceAccountID *xdr.AccountId, sourceAsset xdr.Asset, amountToSpend xdr.Int64, destinationAsset xdr.Asset, ) ([]Path, error)
FindFixedPaths returns a list of payment paths where the source and destination assets are fixed. All returned payment paths will start by spending `amountToSpend` of `sourceAsset` and will end with some positive balance of `destinationAsset`. `sourceAccountID` is optional. if `sourceAccountID` is provided then no offers created by `sourceAccountID` will be considered when evaluating payment paths
func (*OrderBookGraph) FindPaths ¶
func (graph *OrderBookGraph) FindPaths( maxPathLength int, destinationAsset xdr.Asset, destinationAmount xdr.Int64, sourceAccountID xdr.AccountId, sourceAssets []xdr.Asset, sourceAssetBalances []xdr.Int64, maxAssetsPerPath int, ) ([]Path, error)
FindPaths returns a list of payment paths originating from a source account and ending with a given destinaton asset and amount.
func (*OrderBookGraph) IsEmpty ¶
func (graph *OrderBookGraph) IsEmpty() bool
IsEmpty returns true if the orderbook graph is not populated
func (*OrderBookGraph) Offers ¶
func (graph *OrderBookGraph) Offers() []xdr.OfferEntry
Offers returns a list of offers contained in the order book
func (*OrderBookGraph) RemoveOffer ¶
func (graph *OrderBookGraph) RemoveOffer(offerID xdr.Int64) *OrderBookGraph
RemoveOffer will queue an operation to remove the given offer from the order book in the internal batch. You need to run Apply() to apply all enqueued operations.