Improve path filtering:

1) Ignore paths with very low liquidity
2) Allow an extra filling path to be added if needed
This commit is contained in:
JoelKatz
2013-11-02 17:40:44 -07:00
parent 3296ac5628
commit 6b2f654a30
4 changed files with 64 additions and 19 deletions

View File

@@ -172,7 +172,8 @@ Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool
Pathfinder pf (cache, raSrcAddressID, dstAccountID,
saSendMax.getCurrency (), saSendMax.getIssuer (), saSend, bValid);
if (!bValid || !pf.findPaths (getConfig ().PATH_SEARCH_OLD, 4, spsPaths))
STPath extraPath;
if (!bValid || !pf.findPaths (getConfig ().PATH_SEARCH_OLD, 4, spsPaths, extraPath))
{
WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: No paths found.";
@@ -1560,7 +1561,8 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
int level = getConfig().PATH_SEARCH_OLD;
if ((getConfig().PATH_SEARCH_MAX > level) && !getApp().getFeeTrack().isLoadedLocal())
++level;
if (!bValid || !pf.findPaths (level, 4, spsComputed))
STPath extraPath;
if (!bValid || !pf.findPaths (level, 4, spsComputed, extraPath))
{
WriteLog (lsWARNING, RPCHandler) << "ripple_path_find: No paths found.";
}
@@ -1608,6 +1610,18 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
% saMaxAmountAct
% saDstAmountAct);
if ((extraPath.size() > 0) && ((terResult == terNO_LINE) || (terResult == tecPATH_PARTIAL)))
{
WriteLog (lsDEBUG, PathRequest) << "Trying with an extra path element";
spsComputed.addPath(extraPath);
vpsExpanded.clear ();
terResult = RippleCalc::rippleCalc (lesSandbox, saMaxAmountAct, saDstAmountAct,
vpsExpanded, saMaxAmount, saDstAmount,
raDst.getAccountID (), raSrc.getAccountID (),
spsComputed, false, false, false, true);
WriteLog (lsDEBUG, PathRequest) << "Extra path element gives " << transHuman (terResult);
}
if (tesSUCCESS == terResult)
{
Json::Value jvEntry (Json::objectValue);