xrpld
Loading...
Searching...
No Matches
xrpl::Pathfinder Class Reference

Calculates payment paths. More...

#include <Pathfinder.h>

Inheritance diagram for xrpl::Pathfinder:
Collaboration diagram for xrpl::Pathfinder:

Classes

struct  PathRank

Public Types

enum class  NodeType {
  Source , Accounts , Books , XrpBook ,
  DestBook , Destination
}
enum class  PaymentType {
  XrpToXrp , XrpToNonXrp , NonXrpToXrp , NonXrpToSame ,
  NonXrpToNonXrp
}
using PathType = std::vector<NodeType>

Public Member Functions

 Pathfinder (std::shared_ptr< AssetCache > const &cache, AccountID const &srcAccount, AccountID const &dstAccount, PathAsset const &uSrcPathAsset, std::optional< AccountID > const &uSrcIssuer, STAmount const &dstAmount, std::optional< STAmount > const &srcAmount, std::optional< uint256 > const &domain, Application &app)
 Construct a pathfinder without an issuer.
 Pathfinder (Pathfinder const &)=delete
Pathfinderoperator= (Pathfinder const &)=delete
 ~Pathfinder ()=default
bool findPaths (int searchLevel, std::function< bool(void)> const &continueCallback={})
void computePathRanks (int maxPaths, std::function< bool(void)> const &continueCallback={})
 Compute the rankings of the paths.
STPathSet getBestPaths (int maxPaths, STPath &fullLiquidityPath, STPathSet const &extraPaths, AccountID const &srcIssuer, std::function< bool(void)> const &continueCallback={})

Static Public Member Functions

static void initPathTable ()

Public Attributes

friend Object

Private Member Functions

STPathSetaddPathsForType (PathType const &type, std::function< bool(void)> const &continueCallback)
bool issueMatchesOrigin (Asset const &)
int getPathsOut (PathAsset const &pathAsset, AccountID const &account, LineDirection direction, bool isDestPathAsset, AccountID const &dest, std::function< bool(void)> const &continueCallback)
void addLink (STPath const &currentPath, STPathSet &incompletePaths, int addFlags, std::function< bool(void)> const &continueCallback)
void addLinks (STPathSet const &currentPaths, STPathSet &incompletePaths, int addFlags, std::function< bool(void)> const &continueCallback)
TER getPathLiquidity (STPath const &path, STAmount const &minDstAmount, STAmount &amountOut, uint64_t &qualityOut) const
bool isNoRippleOut (STPath const &currentPath)
bool isNoRipple (AccountID const &fromAccount, AccountID const &toAccount, Currency const &currency)
void rankPaths (int maxPaths, STPathSet const &paths, std::vector< PathRank > &rankedPaths, std::function< bool(void)> const &continueCallback)

Static Private Member Functions

static auto & getCounter () noexcept

Private Attributes

AccountID srcAccount_
AccountID dstAccount_
AccountID effectiveDst_
STAmount dstAmount_
PathAsset srcPathAsset_
std::optional< AccountIDsrcIssuer_
STAmount srcAmount_
STAmount remainingAmount_
 The amount remaining from srcAccount_ after the default liquidity has been removed.
bool convertAll_
std::optional< uint256domain_
std::shared_ptr< ReadView const > ledger_
std::unique_ptr< LoadEventloadEvent_
std::shared_ptr< AssetCacherLCache_
STPathElement source_
STPathSet completePaths_
std::vector< PathRankpathRanks_
std::map< PathType, STPathSetpaths_
hash_map< Asset, int > pathsOutCountMap_
Applicationapp_
beast::Journal const j_

Static Private Attributes

static std::uint32_t const kAfAddAccounts = 0x001
static std::uint32_t const kAfAddBooks = 0x002
static std::uint32_t const kAfObXrp = 0x010
static std::uint32_t const kAfObLast = 0x040
static std::uint32_t const kAfAcLast = 0x080

Detailed Description

Calculates payment paths.

The RippleCalc determines the quality of the found paths.

See also
RippleCalc

Definition at line 21 of file Pathfinder.h.

Member Typedef Documentation

◆ PathType

Definition at line 73 of file Pathfinder.h.

Member Enumeration Documentation

◆ NodeType

enum class xrpl::Pathfinder::NodeType
strong
Enumerator
Source 
Accounts 
Books 
XrpBook 
DestBook 
Destination 

Definition at line 63 of file Pathfinder.h.

◆ PaymentType

enum class xrpl::Pathfinder::PaymentType
strong
Enumerator
XrpToXrp 
XrpToNonXrp 
NonXrpToXrp 
NonXrpToSame 
NonXrpToNonXrp 

Definition at line 77 of file Pathfinder.h.

Constructor & Destructor Documentation

◆ Pathfinder() [1/2]

xrpl::Pathfinder::Pathfinder ( std::shared_ptr< AssetCache > const & cache,
AccountID const & srcAccount,
AccountID const & dstAccount,
PathAsset const & uSrcPathAsset,
std::optional< AccountID > const & uSrcIssuer,
STAmount const & dstAmount,
std::optional< STAmount > const & srcAmount,
std::optional< uint256 > const & domain,
Application & app )

Construct a pathfinder without an issuer.

Definition at line 211 of file Pathfinder.cpp.

◆ Pathfinder() [2/2]

xrpl::Pathfinder::Pathfinder ( Pathfinder const & )
delete

◆ ~Pathfinder()

xrpl::Pathfinder::~Pathfinder ( )
default

Member Function Documentation

◆ operator=()

Pathfinder & xrpl::Pathfinder::operator= ( Pathfinder const & )
delete

◆ initPathTable()

void xrpl::Pathfinder::initPathTable ( )
static

Definition at line 1371 of file Pathfinder.cpp.

◆ findPaths()

bool xrpl::Pathfinder::findPaths ( int searchLevel,
std::function< bool(void)> const & continueCallback = {} )

Definition at line 241 of file Pathfinder.cpp.

◆ computePathRanks()

void xrpl::Pathfinder::computePathRanks ( int maxPaths,
std::function< bool(void)> const & continueCallback = {} )

Compute the rankings of the paths.

Definition at line 451 of file Pathfinder.cpp.

◆ getBestPaths()

STPathSet xrpl::Pathfinder::getBestPaths ( int maxPaths,
STPath & fullLiquidityPath,
STPathSet const & extraPaths,
AccountID const & srcIssuer,
std::function< bool(void)> const & continueCallback = {} )

Definition at line 604 of file Pathfinder.cpp.

◆ addPathsForType()

STPathSet & xrpl::Pathfinder::addPathsForType ( PathType const & type,
std::function< bool(void)> const & continueCallback )
private

Definition at line 854 of file Pathfinder.cpp.

◆ issueMatchesOrigin()

bool xrpl::Pathfinder::issueMatchesOrigin ( Asset const & asset)
private

Definition at line 738 of file Pathfinder.cpp.

◆ getPathsOut()

int xrpl::Pathfinder::getPathsOut ( PathAsset const & pathAsset,
AccountID const & account,
LineDirection direction,
bool isDestPathAsset,
AccountID const & dest,
std::function< bool(void)> const & continueCallback )
private

Definition at line 748 of file Pathfinder.cpp.

◆ addLink()

void xrpl::Pathfinder::addLink ( STPath const & currentPath,
STPathSet & incompletePaths,
int addFlags,
std::function< bool(void)> const & continueCallback )
private

Definition at line 976 of file Pathfinder.cpp.

◆ addLinks()

void xrpl::Pathfinder::addLinks ( STPathSet const & currentPaths,
STPathSet & incompletePaths,
int addFlags,
std::function< bool(void)> const & continueCallback )
private

Definition at line 838 of file Pathfinder.cpp.

◆ getPathLiquidity()

TER xrpl::Pathfinder::getPathLiquidity ( STPath const & path,
STAmount const & minDstAmount,
STAmount & amountOut,
uint64_t & qualityOut ) const
private

Definition at line 382 of file Pathfinder.cpp.

◆ isNoRippleOut()

bool xrpl::Pathfinder::isNoRippleOut ( STPath const & currentPath)
private

Definition at line 942 of file Pathfinder.cpp.

◆ isNoRipple()

bool xrpl::Pathfinder::isNoRipple ( AccountID const & fromAccount,
AccountID const & toAccount,
Currency const & currency )
private

Definition at line 927 of file Pathfinder.cpp.

◆ rankPaths()

void xrpl::Pathfinder::rankPaths ( int maxPaths,
STPathSet const & paths,
std::vector< PathRank > & rankedPaths,
std::function< bool(void)> const & continueCallback )
private

Definition at line 526 of file Pathfinder.cpp.

◆ getCounter()

auto & xrpl::CountedObject< Pathfinder >::getCounter ( )
staticprivatenoexceptinherited

Definition at line 109 of file CountedObject.h.

Member Data Documentation

◆ srcAccount_

AccountID xrpl::Pathfinder::srcAccount_
private

Definition at line 171 of file Pathfinder.h.

◆ dstAccount_

AccountID xrpl::Pathfinder::dstAccount_
private

Definition at line 172 of file Pathfinder.h.

◆ effectiveDst_

AccountID xrpl::Pathfinder::effectiveDst_
private

Definition at line 173 of file Pathfinder.h.

◆ dstAmount_

STAmount xrpl::Pathfinder::dstAmount_
private

Definition at line 174 of file Pathfinder.h.

◆ srcPathAsset_

PathAsset xrpl::Pathfinder::srcPathAsset_
private

Definition at line 175 of file Pathfinder.h.

◆ srcIssuer_

std::optional<AccountID> xrpl::Pathfinder::srcIssuer_
private

Definition at line 176 of file Pathfinder.h.

◆ srcAmount_

STAmount xrpl::Pathfinder::srcAmount_
private

Definition at line 177 of file Pathfinder.h.

◆ remainingAmount_

STAmount xrpl::Pathfinder::remainingAmount_
private

The amount remaining from srcAccount_ after the default liquidity has been removed.

Definition at line 180 of file Pathfinder.h.

◆ convertAll_

bool xrpl::Pathfinder::convertAll_
private

Definition at line 181 of file Pathfinder.h.

◆ domain_

std::optional<uint256> xrpl::Pathfinder::domain_
private

Definition at line 182 of file Pathfinder.h.

◆ ledger_

std::shared_ptr<ReadView const> xrpl::Pathfinder::ledger_
private

Definition at line 184 of file Pathfinder.h.

◆ loadEvent_

std::unique_ptr<LoadEvent> xrpl::Pathfinder::loadEvent_
private

Definition at line 185 of file Pathfinder.h.

◆ rLCache_

std::shared_ptr<AssetCache> xrpl::Pathfinder::rLCache_
private

Definition at line 186 of file Pathfinder.h.

◆ source_

STPathElement xrpl::Pathfinder::source_
private

Definition at line 188 of file Pathfinder.h.

◆ completePaths_

STPathSet xrpl::Pathfinder::completePaths_
private

Definition at line 189 of file Pathfinder.h.

◆ pathRanks_

std::vector<PathRank> xrpl::Pathfinder::pathRanks_
private

Definition at line 190 of file Pathfinder.h.

◆ paths_

std::map<PathType, STPathSet> xrpl::Pathfinder::paths_
private

Definition at line 191 of file Pathfinder.h.

◆ pathsOutCountMap_

hash_map<Asset, int> xrpl::Pathfinder::pathsOutCountMap_
private

Definition at line 193 of file Pathfinder.h.

◆ app_

Application& xrpl::Pathfinder::app_
private

Definition at line 195 of file Pathfinder.h.

◆ j_

beast::Journal const xrpl::Pathfinder::j_
private

Definition at line 196 of file Pathfinder.h.

◆ kAfAddAccounts

std::uint32_t const xrpl::Pathfinder::kAfAddAccounts = 0x001
staticprivate

Definition at line 199 of file Pathfinder.h.

◆ kAfAddBooks

std::uint32_t const xrpl::Pathfinder::kAfAddBooks = 0x002
staticprivate

Definition at line 202 of file Pathfinder.h.

◆ kAfObXrp

std::uint32_t const xrpl::Pathfinder::kAfObXrp = 0x010
staticprivate

Definition at line 205 of file Pathfinder.h.

◆ kAfObLast

std::uint32_t const xrpl::Pathfinder::kAfObLast = 0x040
staticprivate

Definition at line 208 of file Pathfinder.h.

◆ kAfAcLast

std::uint32_t const xrpl::Pathfinder::kAfAcLast = 0x080
staticprivate

Definition at line 211 of file Pathfinder.h.

◆ Object

Definition at line 134 of file CountedObject.h.