TER PathCursor::advanceNode (STAmount const& amount, bool reverse) const { bool multi = multiQuality_ || amount == zero; // If the multiQuality_ is unchanged, use the PathCursor we're using now. if (multi == multiQuality_) return advanceNode (reverse); // Otherwise, use a new PathCursor with the new multiQuality_. PathCursor withMultiQuality {rippleCalc_, pathState_, multi, nodeIndex_}; return withMultiQuality.advanceNode (reverse); }
TER PathCursor::advanceNode (STAmount const& amount, bool reverse, bool callerHasLiquidity) const { bool const multi = fix1141 (view ().info ().parentCloseTime) ? (multiQuality_ || (!callerHasLiquidity && amount == beast::zero)) : (multiQuality_ || amount == beast::zero); // If the multiQuality_ is unchanged, use the PathCursor we're using now. if (multi == multiQuality_) return advanceNode (reverse); // Otherwise, use a new PathCursor with the new multiQuality_. PathCursor withMultiQuality {rippleCalc_, pathState_, multi, j_, nodeIndex_}; return withMultiQuality.advanceNode (reverse); }
TER PathCursor::liquidity () const { TER resultCode = tecPATH_DRY; PathCursor pc = *this; pathState_.resetView (rippleCalc_.view); for (pc.nodeIndex_ = pc.nodeSize(); pc.nodeIndex_--; ) { JLOG (j_.trace()) << "reverseLiquidity>" << " nodeIndex=" << pc.nodeIndex_ << ".issue_.account=" << to_string (pc.node().issue_.account); resultCode = pc.reverseLiquidity(); if (!pc.node().transferRate_) return tefINTERNAL; JLOG (j_.trace()) << "reverseLiquidity< " << "nodeIndex=" << pc.nodeIndex_ << " resultCode=" << transToken (resultCode) << " transferRate_=" << *pc.node().transferRate_ << ": " << resultCode; if (resultCode != tesSUCCESS) break; } // VFALCO-FIXME this generates errors // JLOG (j_.trace()) // << "nextIncrement: Path after reverse: " << pathState_.getJson (); if (resultCode != tesSUCCESS) return resultCode; pathState_.resetView (rippleCalc_.view); for (pc.nodeIndex_ = 0; pc.nodeIndex_ < pc.nodeSize(); ++pc.nodeIndex_) { JLOG (j_.trace()) << "forwardLiquidity> nodeIndex=" << nodeIndex_; resultCode = pc.forwardLiquidity(); if (resultCode != tesSUCCESS) return resultCode; JLOG (j_.trace()) << "forwardLiquidity<" << " nodeIndex:" << pc.nodeIndex_ << " resultCode:" << resultCode; if (pathState_.isDry()) resultCode = tecPATH_DRY; } return resultCode; }