Documentation ¶
Overview ¶
Package paths provides utilities and facilities for payment paths as needed by aurora. Most importantly, it provides the Finder interface, allowing for pluggable path finding back ends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRateLimitExceeded indicates that the Finder is not able to fulfill the request due to rate limits. ErrRateLimitExceeded = errors.New("Rate limit exceeded") )
Functions ¶
This section is empty.
Types ¶
type Finder ¶
type Finder interface { // Find returns a list of payment paths and the most recent ledger // for a Query of a maximum length `maxLength`. The payment paths // are accurate and consistent with the returned ledger sequence number Find(ctx context.Context, q Query, maxLength uint) ([]Path, uint32, error) // FindFixedPaths return a list of payment paths the most recent ledger // Each of the payment paths start by spending `amountToSpend` of `sourceAsset` and end // with delivering a positive amount of `destinationAsset`. // The payment paths are accurate and consistent with the returned ledger sequence number FindFixedPaths( ctx context.Context, sourceAsset xdr.Asset, amountToSpend xdr.Int64, destinationAssets []xdr.Asset, maxLength uint, ) ([]Path, uint32, error) }
Finder finds paths.
type MockFinder ¶ added in v1.11.1
MockFinder is a mock implementation of the Finder interface
type Path ¶
type Path struct { Path []string Source string SourceAmount xdr.Int64 Destination string DestinationAmount xdr.Int64 }
Path is the result returned by a path finder and is tied to the DestinationAmount used in the input query
type Query ¶
type Query struct { DestinationAsset xdr.Asset DestinationAmount xdr.Int64 SourceAssets []xdr.Asset SourceAssetBalances []xdr.Int64 // if ValidateSourceBalance is true then we won't consider payment paths // which require a source asset amount which exceeds the balance present in `SourceAssetBalances` ValidateSourceBalance bool SourceAccount *xdr.AccountId }
Query is a query for paths
type RateLimitedFinder ¶ added in v1.11.1
type RateLimitedFinder struct {
// contains filtered or unexported fields
}
RateLimitedFinder is a Finder implementation which limits the number of path finding requests.
func NewRateLimitedFinder ¶ added in v1.11.1
func NewRateLimitedFinder(finder Finder, limit uint) *RateLimitedFinder
NewRateLimitedFinder constructs a new RateLimitedFinder which enforces a per second limit on path finding requests.
func (*RateLimitedFinder) Find ¶ added in v1.11.1
func (f *RateLimitedFinder) Find(ctx context.Context, q Query, maxLength uint) ([]Path, uint32, error)
Find implements the Finder interface and returns ErrRateLimitExceeded if the RateLimitedFinder is unable to complete the request due to rate limits.
func (*RateLimitedFinder) FindFixedPaths ¶ added in v1.11.1
func (f *RateLimitedFinder) FindFixedPaths( ctx context.Context, sourceAsset xdr.Asset, amountToSpend xdr.Int64, destinationAssets []xdr.Asset, maxLength uint, ) ([]Path, uint32, error)
FindFixedPaths implements the Finder interface and returns ErrRateLimitExceeded if the RateLimitedFinder is unable to complete the request due to rate limits.
func (*RateLimitedFinder) Limit ¶ added in v1.11.1
func (f *RateLimitedFinder) Limit() int
Limit returns the per second limit of path finding requests.