Skip to content

Commit

Permalink
[fold] continueCallback should be passed by const&
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Feb 14, 2022
1 parent ee93205 commit 97ede1e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/ripple/app/paths/PathRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ PathRequest::getPathFinder(
Currency const& currency,
STAmount const& dst_amount,
int const level,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
auto i = currency_map.find(currency);
if (i != currency_map.end())
Expand All @@ -496,7 +496,7 @@ PathRequest::findPaths(
std::shared_ptr<RippleLineCache> const& cache,
int const level,
Json::Value& jvArray,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
auto sourceCurrencies = sciSourceCurrencies;
if (sourceCurrencies.empty() && saSendMax)
Expand Down Expand Up @@ -650,7 +650,7 @@ Json::Value
PathRequest::doUpdate(
std::shared_ptr<RippleLineCache> const& cache,
bool fast,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
using namespace std::chrono;
JLOG(m_journal.debug())
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/app/paths/PathRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class PathRequest final : public InfoSubRequest,
doUpdate(
std::shared_ptr<RippleLineCache> const&,
bool fast,
std::function<bool(void)> continueCallback = {});
std::function<bool(void)> const& continueCallback = {});
InfoSub::pointer
getSubscriber();
bool
Expand All @@ -117,7 +117,7 @@ class PathRequest final : public InfoSubRequest,
Currency const&,
STAmount const&,
int const,
std::function<bool(void)>);
std::function<bool(void)> const&);

/** Finds and sets a PathSet in the JSON argument.
Returns false if the source currencies are inavlid.
Expand All @@ -127,7 +127,7 @@ class PathRequest final : public InfoSubRequest,
std::shared_ptr<RippleLineCache> const&,
int const,
Json::Value&,
std::function<bool(void)>);
std::function<bool(void)> const&);

int
parseJson(Json::Value const&);
Expand Down
16 changes: 8 additions & 8 deletions src/ripple/app/paths/Pathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Pathfinder::Pathfinder(
bool
Pathfinder::findPaths(
int searchLevel,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
JLOG(j_.trace()) << "findPaths start";
if (mDstAmount == beast::zero)
Expand Down Expand Up @@ -423,7 +423,7 @@ Pathfinder::getPathLiquidity(
void
Pathfinder::computePathRanks(
int maxPaths,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
mRemainingAmount = convertAmount(mDstAmount, convert_all_);

Expand Down Expand Up @@ -503,7 +503,7 @@ Pathfinder::rankPaths(
int maxPaths,
STPathSet const& paths,
std::vector<PathRank>& rankedPaths,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
JLOG(j_.trace()) << "rankPaths with " << paths.size() << " candidates, and "
<< maxPaths << " maximum";
Expand Down Expand Up @@ -582,7 +582,7 @@ Pathfinder::getBestPaths(
STPath& fullLiquidityPath,
STPathSet const& extraPaths,
AccountID const& srcIssuer,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
JLOG(j_.debug()) << "findPaths: " << mCompletePaths.size() << " paths and "
<< extraPaths.size() << " extras";
Expand Down Expand Up @@ -723,7 +723,7 @@ Pathfinder::getPathsOut(
AccountID const& account,
bool isDstCurrency,
AccountID const& dstAccount,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
Issue const issue(currency, account);

Expand Down Expand Up @@ -787,7 +787,7 @@ Pathfinder::addLinks(
STPathSet const& currentPaths, // The paths to build from
STPathSet& incompletePaths, // The set of partial paths we add to
int addFlags,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
JLOG(j_.debug()) << "addLink< on " << currentPaths.size()
<< " source(s), flags=" << addFlags;
Expand All @@ -802,7 +802,7 @@ Pathfinder::addLinks(
STPathSet&
Pathfinder::addPathsForType(
PathType const& pathType,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
JLOG(j_.warn()) << "addPathsForType " << pathType;
// See if the set of paths for this type already exists.
Expand Down Expand Up @@ -945,7 +945,7 @@ Pathfinder::addLink(
const STPath& currentPath, // The path to build from
STPathSet& incompletePaths, // The set of partial paths we add to
int addFlags,
std::function<bool(void)> continueCallback)
std::function<bool(void)> const& continueCallback)
{
auto const& pathEnd = currentPath.empty() ? mSource : currentPath.back();
auto const& uEndCurrency = pathEnd.getCurrency();
Expand Down
18 changes: 10 additions & 8 deletions src/ripple/app/paths/Pathfinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ class Pathfinder : public CountedObject<Pathfinder>
initPathTable();

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

/** Compute the rankings of the paths. */
void
computePathRanks(
int maxPaths,
std::function<bool(void)> continueCallback = {});
std::function<bool(void)> const& continueCallback = {});

/* Get the best paths, up to maxPaths in number, from mCompletePaths.
Expand All @@ -76,7 +78,7 @@ class Pathfinder : public CountedObject<Pathfinder>
STPath& fullLiquidityPath,
STPathSet const& extraPaths,
AccountID const& srcIssuer,
std::function<bool(void)> continueCallback = {});
std::function<bool(void)> const& continueCallback = {});

enum NodeType {
nt_SOURCE, // The source account: with an issuer account, if needed.
Expand Down Expand Up @@ -133,7 +135,7 @@ class Pathfinder : public CountedObject<Pathfinder>
STPathSet&
addPathsForType(
PathType const& type,
std::function<bool(void)> continueCallback);
std::function<bool(void)> const& continueCallback);

bool
issueMatchesOrigin(Issue const&);
Expand All @@ -144,22 +146,22 @@ class Pathfinder : public CountedObject<Pathfinder>
AccountID const& account,
bool isDestCurrency,
AccountID const& dest,
std::function<bool(void)> continueCallback);
std::function<bool(void)> const& continueCallback);

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

// Call addLink() for each path in currentPaths.
void
addLinks(
STPathSet const& currentPaths,
STPathSet& incompletePaths,
int addFlags,
std::function<bool(void)> continueCallback);
std::function<bool(void)> const& continueCallback);

// Compute the liquidity for a path. Return tesSUCCESS if it has has enough
// liquidity to be worth keeping, otherwise an error.
Expand Down Expand Up @@ -188,7 +190,7 @@ class Pathfinder : public CountedObject<Pathfinder>
int maxPaths,
STPathSet const& paths,
std::vector<PathRank>& rankedPaths,
std::function<bool(void)> continueCallback);
std::function<bool(void)> const& continueCallback);

AccountID mSrcAccount;
AccountID mDstAccount;
Expand Down

0 comments on commit 97ede1e

Please sign in to comment.