From df9884f48efb913bb44e5d79cab5305cb9b9aa2f Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 3 Mar 2013 23:52:13 -0800 Subject: [PATCH] Cleanups. --- src/cpp/ripple/RippleCalc.cpp | 68 ++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/src/cpp/ripple/RippleCalc.cpp b/src/cpp/ripple/RippleCalc.cpp index e1c41077a..99a003ccf 100644 --- a/src/cpp/ripple/RippleCalc.cpp +++ b/src/cpp/ripple/RippleCalc.cpp @@ -325,10 +325,10 @@ void PathState::setExpanded( uMaxCurrencyID, // Max specifes the currency. uSenderIssuerID); -cLog(lsDEBUG) << boost::str(boost::format("PathState: pushed: account=%s currency=%s issuer=%s") - % RippleAddress::createHumanAccountID(uSenderID) - % STAmount::createHumanCurrency(uMaxCurrencyID) - % RippleAddress::createHumanAccountID(uSenderIssuerID)); + cLog(lsDEBUG) << boost::str(boost::format("PathState: pushed: account=%s currency=%s issuer=%s") + % RippleAddress::createHumanAccountID(uSenderID) + % STAmount::createHumanCurrency(uMaxCurrencyID) + % RippleAddress::createHumanAccountID(uSenderIssuerID)); if (tesSUCCESS == terStatus && uMaxIssuerID != uSenderIssuerID) { // Issuer was not same as sender. @@ -347,19 +347,19 @@ cLog(lsDEBUG) << boost::str(boost::format("PathState: pushed: account=%s currenc : uOutIssuerID // Use implied node. : ACCOUNT_XRP; -cLog(lsDEBUG) << boost::str(boost::format("PathState: implied check: uNxtCurrencyID=%s uNxtAccountID=%s") - % RippleAddress::createHumanAccountID(uNxtCurrencyID) - % RippleAddress::createHumanAccountID(uNxtAccountID)); + cLog(lsDEBUG) << boost::str(boost::format("PathState: implied check: uNxtCurrencyID=%s uNxtAccountID=%s") + % RippleAddress::createHumanAccountID(uNxtCurrencyID) + % RippleAddress::createHumanAccountID(uNxtAccountID)); // Can't just use push implied, because it can't compensate for next account. if (!uNxtCurrencyID // Next is XRP, offer next. Must go through issuer. || uMaxCurrencyID != uNxtCurrencyID // Next is different currency, offer next... || uMaxIssuerID != uNxtAccountID) // Next is not implied issuer { -cLog(lsDEBUG) << boost::str(boost::format("PathState: sender implied: account=%s currency=%s issuer=%s") - % RippleAddress::createHumanAccountID(uMaxIssuerID) - % RippleAddress::createHumanAccountID(uMaxCurrencyID) - % RippleAddress::createHumanAccountID(uMaxIssuerID)); + cLog(lsDEBUG) << boost::str(boost::format("PathState: sender implied: account=%s currency=%s issuer=%s") + % RippleAddress::createHumanAccountID(uMaxIssuerID) + % RippleAddress::createHumanAccountID(uMaxCurrencyID) + % RippleAddress::createHumanAccountID(uMaxIssuerID)); // Add account implied by SendMax. terStatus = pushNode( !!uMaxCurrencyID @@ -375,7 +375,7 @@ cLog(lsDEBUG) << boost::str(boost::format("PathState: sender implied: account=%s { if (tesSUCCESS == terStatus) { -cLog(lsDEBUG) << boost::str(boost::format("PathState: element in path:")); + cLog(lsDEBUG) << boost::str(boost::format("PathState: element in path:")); terStatus = pushNode(speElement.getNodeType(), speElement.getAccountID(), speElement.getCurrency(), speElement.getIssuerID()); } } @@ -389,10 +389,10 @@ cLog(lsDEBUG) << boost::str(boost::format("PathState: element in path:")); || pnPrv.uAccountID != uOutIssuerID)) // Need the implied issuer. { // Add implied account. -cLog(lsDEBUG) << boost::str(boost::format("PathState: receiver implied: account=%s currency=%s issuer=%s") - % RippleAddress::createHumanAccountID(uOutIssuerID) - % RippleAddress::createHumanAccountID(uOutCurrencyID) - % RippleAddress::createHumanAccountID(uOutIssuerID)); + cLog(lsDEBUG) << boost::str(boost::format("PathState: receiver implied: account=%s currency=%s issuer=%s") + % RippleAddress::createHumanAccountID(uOutIssuerID) + % RippleAddress::createHumanAccountID(uOutCurrencyID) + % RippleAddress::createHumanAccountID(uOutIssuerID)); terStatus = pushNode( !!uOutCurrencyID ? STPathElement::typeAccount | STPathElement::typeCurrency | STPathElement::typeIssuer @@ -2495,9 +2495,9 @@ int iIndex = 0; pspExpanded->setExpanded(lesActive, spPath, uDstAccountID, uSrcAccountID); -cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Build path: %d: status: %s") - % ++iIndex - % transToken(pspExpanded->terStatus)); + cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Build path: %d: status: %s") + % ++iIndex + % transToken(pspExpanded->terStatus)); // Return, if the path specification was malformed. if (isTemMalformed(pspExpanded->terStatus)) @@ -2551,17 +2551,18 @@ int iPass = 0; pspCur->saOutAct = saDstAmountAct; rc.pathNext(pspCur, bMultiQuality, lesCheckpoint, lesActive); // Compute increment. - cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: AFTER: mIndex=%d uQuality=%d rate=%s") - % pspCur->mIndex - % pspCur->uQuality - % STAmount::saFromRate(pspCur->uQuality)); + cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: AFTER: mIndex=%d uQuality=%d rate=%s") + % pspCur->mIndex + % pspCur->uQuality + % STAmount::saFromRate(pspCur->uQuality)); if (!pspCur->uQuality) { // Path was dry. ++iDry; } - else { + else + { tLog(!pspCur->saInPass || !pspCur->saOutPass, lsDEBUG) << boost::str(boost::format("rippleCalc: better: uQuality=%s saInPass=%s saOutPass=%s") % STAmount::saFromRate(pspCur->uQuality) @@ -2587,15 +2588,18 @@ int iPass = 0; } } } -cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Summary: Pass: %d Dry: %d Paths: %d") % ++iPass % iDry % vpsExpanded.size()); - BOOST_FOREACH(PathState::ref pspCur, vpsExpanded) + if (sLog(lsDEBUG)) { -cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Summary: %d rate: %s quality:%d best: %d consumed: %d") - % pspCur->mIndex - % STAmount::saFromRate(pspCur->uQuality) - % pspCur->uQuality - % (iBest == pspCur->getIndex()) - % pspCur->bConsumed); + cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Summary: Pass: %d Dry: %d Paths: %d") % ++iPass % iDry % vpsExpanded.size()); + BOOST_FOREACH(PathState::ref pspCur, vpsExpanded) + { + cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Summary: %d rate: %s quality:%d best: %d consumed: %d") + % pspCur->mIndex + % STAmount::saFromRate(pspCur->uQuality) + % pspCur->uQuality + % (iBest == pspCur->getIndex()) + % pspCur->bConsumed); + } } if (iBest >= 0)