mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix ripple calc looping on errors.
This commit is contained in:
@@ -1816,21 +1816,25 @@ void RippleCalc::pathNext(const PathState::pointer& pspCur, const int iPaths, co
|
|||||||
lesCurrent.bumpSeq(); // Begin ledger varance.
|
lesCurrent.bumpSeq(); // Begin ledger varance.
|
||||||
|
|
||||||
pspCur->terStatus = calcNodeFwd(0, pspCur, bMultiQuality);
|
pspCur->terStatus = calcNodeFwd(0, pspCur, bMultiQuality);
|
||||||
|
}
|
||||||
|
|
||||||
tLog(tesSUCCESS == pspCur->terStatus, lsDEBUG)
|
if (tesSUCCESS == pspCur->terStatus)
|
||||||
|
{
|
||||||
|
tLog(!pspCur->saInPass || !pspCur->saOutPass, lsDEBUG)
|
||||||
<< boost::str(boost::format("saOutPass=%s saInPass=%s")
|
<< boost::str(boost::format("saOutPass=%s saInPass=%s")
|
||||||
% pspCur->saOutPass.getFullText()
|
% pspCur->saOutPass.getFullText()
|
||||||
% pspCur->saInPass.getFullText());
|
% pspCur->saInPass.getFullText());
|
||||||
|
|
||||||
// Make sure we have a quality.
|
assert(!!pspCur->saOutPass && !!pspCur->saInPass);
|
||||||
assert(tesSUCCESS != pspCur->terStatus || (!!pspCur->saOutPass && !!pspCur->saInPass));
|
|
||||||
|
|
||||||
pspCur->uQuality = tesSUCCESS == pspCur->terStatus
|
pspCur->uQuality = STAmount::getRate(pspCur->saOutPass, pspCur->saInPass); // Calculate relative quality.
|
||||||
? STAmount::getRate(pspCur->saOutPass, pspCur->saInPass) // Calculate relative quality.
|
|
||||||
: 0; // Mark path as inactive.
|
|
||||||
|
|
||||||
cLog(lsINFO) << "Path after forward: " << pspCur->getJson();
|
cLog(lsINFO) << "Path after forward: " << pspCur->getJson();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pspCur->uQuality = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Stand alone calculation not implemented, does not calculate required input.
|
// XXX Stand alone calculation not implemented, does not calculate required input.
|
||||||
@@ -1968,12 +1972,27 @@ TER RippleCalc::rippleCalc(
|
|||||||
|
|
||||||
nothing();
|
nothing();
|
||||||
}
|
}
|
||||||
else if ((!bLimitQuality || pspCur->uQuality <= uQualityLimit) // Quality is not limted or increment has allowed quality.
|
else {
|
||||||
|| !pspBest // Best is not yet set.
|
tLog(!pspCur->saInPass || !pspCur->saOutPass, lsDEBUG)
|
||||||
|| PathState::lessPriority(pspBest, pspCur)) // Current is better than set.
|
<< boost::str(boost::format("calcOfferFirst: better: uQuality=%016lX saInPass=%s saOutPass=%s")
|
||||||
{
|
% pspCur->uQuality
|
||||||
lesActive.swapWith(pspCur->lesEntries); // For the path, save ledger state.
|
% pspCur->saInPass.getFullText()
|
||||||
pspBest = pspCur;
|
% pspCur->saOutPass.getFullText());
|
||||||
|
|
||||||
|
assert(!!pspCur->saInPass && !!pspCur->saOutPass);
|
||||||
|
|
||||||
|
if ((!bLimitQuality || pspCur->uQuality <= uQualityLimit) // Quality is not limted or increment has allowed quality.
|
||||||
|
|| !pspBest // Best is not yet set.
|
||||||
|
|| PathState::lessPriority(pspBest, pspCur)) // Current is better than set.
|
||||||
|
{
|
||||||
|
cLog(lsDEBUG) << boost::str(boost::format("calcOfferFirst: better: uQuality=%016lX saInPass=%s saOutPass=%s")
|
||||||
|
% pspCur->uQuality
|
||||||
|
% pspCur->saInPass.getFullText()
|
||||||
|
% pspCur->saOutPass.getFullText());
|
||||||
|
|
||||||
|
lesActive.swapWith(pspCur->lesEntries); // For the path, save ledger state.
|
||||||
|
pspBest = pspCur;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1982,6 +2001,11 @@ TER RippleCalc::rippleCalc(
|
|||||||
{
|
{
|
||||||
// Apply best path.
|
// Apply best path.
|
||||||
|
|
||||||
|
cLog(lsDEBUG) << boost::str(boost::format("calcOfferFirst: best: uQuality=%016lX saInPass=%s saOutPass=%s")
|
||||||
|
% pspBest->uQuality
|
||||||
|
% pspBest->saInPass.getFullText()
|
||||||
|
% pspBest->saOutPass.getFullText());
|
||||||
|
|
||||||
// Record best pass' offers that became unfunded for deletion on success.
|
// Record best pass' offers that became unfunded for deletion on success.
|
||||||
vuUnfundedBecame.insert(vuUnfundedBecame.end(), pspBest->vUnfundedBecame.begin(), pspBest->vUnfundedBecame.end());
|
vuUnfundedBecame.insert(vuUnfundedBecame.end(), pspBest->vUnfundedBecame.begin(), pspBest->vUnfundedBecame.end());
|
||||||
|
|
||||||
@@ -1991,7 +2015,7 @@ TER RippleCalc::rippleCalc(
|
|||||||
saInAct += pspBest->saInPass;
|
saInAct += pspBest->saInPass;
|
||||||
saOutAct += pspBest->saOutPass;
|
saOutAct += pspBest->saOutPass;
|
||||||
|
|
||||||
if (temUNCERTAIN == terResult && saOutAct == saDstAmountReq)
|
if (saOutAct == saDstAmountReq)
|
||||||
{
|
{
|
||||||
// Done. Delivered requested amount.
|
// Done. Delivered requested amount.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user