diff --git a/src/cpp/ripple/PFRequest.cpp b/src/cpp/ripple/PFRequest.cpp index df9993f4f0..531dd1ab8c 100644 --- a/src/cpp/ripple/PFRequest.cpp +++ b/src/cpp/ripple/PFRequest.cpp @@ -8,8 +8,6 @@ #include "RippleCalc.h" #include "LedgerFormats.h" -SETUP_LOG(); - boost::recursive_mutex PFRequest::sLock; std::set PFRequest::sRequests; @@ -100,9 +98,9 @@ Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value) if (mValid) { - cLog(lsINFO) << "Request created: " << raSrcAccount.humanAccountID() << + WriteLog (lsINFO, PFRequest) << "Request created: " << raSrcAccount.humanAccountID() << " -> " << raDstAccount.humanAccountID(); - cLog(lsINFO) << "Deliver: " << saDstAmount.getFullText(); + WriteLog (lsINFO, PFRequest) << "Deliver: " << saDstAmount.getFullText(); boost::recursive_mutex::scoped_lock sl(sLock); sRequests.insert(shared_from_this()); @@ -248,13 +246,13 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast) { { STAmount test(currIssuer.first, currIssuer.second, 1); - cLog(lsDEBUG) << "Trying to find paths: " << test.getFullText(); + WriteLog (lsDEBUG, PFRequest) << "Trying to find paths: " << test.getFullText(); } bool valid; STPathSet spsPaths; Pathfinder pf(cache, raSrcAccount, raDstAccount, currIssuer.first, currIssuer.second, saDstAmount, valid); - tLog(!valid, lsINFO) << "PF request not valid"; + CondLog (!valid, lsINFO, PFRequest) << "PF request not valid"; if (valid && pf.findPaths(theConfig.PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths)) { LedgerEntrySet lesSandbox(cache->getLedger(), tapNONE); @@ -265,7 +263,7 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast) currIssuer.second.isNonZero() ? currIssuer.second : (currIssuer.first.isZero() ? ACCOUNT_XRP : raSrcAccount.getAccountID()), 1); saMaxAmount.negate(); - cLog(lsDEBUG) << "Paths found, calling rippleCalc"; + WriteLog (lsDEBUG, PFRequest) << "Paths found, calling rippleCalc"; TER terResult = RippleCalc::rippleCalc(lesSandbox, saMaxAmountAct, saDstAmountAct, vpsExpanded, saMaxAmount, saDstAmount, raDstAccount.getAccountID(), raSrcAccount.getAccountID(), spsPaths, false, false, false, true); @@ -278,12 +276,12 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast) } else { - cLog(lsINFO) << "rippleCalc returns " << transHuman(terResult); + WriteLog (lsINFO, PFRequest) << "rippleCalc returns " << transHuman(terResult); } } else { - cLog(lsINFO) << "No paths found"; + WriteLog (lsINFO, PFRequest) << "No paths found"; } } jvStatus["alternatives"] = jvArray; diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index 0a33234c46..2919b5b540 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -8,8 +8,6 @@ #include "Application.h" #include "Log.h" -SETUP_LOG(); - /* we just need to find a succession of the highest quality paths there until we find enough width @@ -74,7 +72,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath) { if (2 >= spPath.mPath.size()) { // Empty path is a default. Don't need to add it to return set. - cLog(lsTRACE) << "findPaths: empty path: direct"; + WriteLog (lsTRACE, Pathfinder) << "findPaths: empty path: direct"; return true; } @@ -95,7 +93,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath) bool bDefault; LedgerEntrySet lesActive(mLedger, tapNONE); - cLog(lsTRACE) << boost::str(boost::format("bDefaultPath> mSrcAmount=%s mDstAmount=%s") + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("bDefaultPath> mSrcAmount=%s mDstAmount=%s") % mSrcAmount.getFullText() % mDstAmount.getFullText()); @@ -107,9 +105,9 @@ bool Pathfinder::bDefaultPath(const STPath& spPath) // When path is a default (implied). Don't need to add it to return set. bDefault = pspCurrent->vpnNodes == mPsDefault->vpnNodes; - cLog(lsTRACE) << "bDefaultPath: expanded path: " << pspCurrent->getJson(); - cLog(lsTRACE) << "bDefaultPath: source path: " << spPath.getJson(0); - cLog(lsTRACE) << "bDefaultPath: default path: " << mPsDefault->getJson(); + WriteLog (lsTRACE, Pathfinder) << "bDefaultPath: expanded path: " << pspCurrent->getJson(); + WriteLog (lsTRACE, Pathfinder) << "bDefaultPath: source path: " << spPath.getJson(0); + WriteLog (lsTRACE, Pathfinder) << "bDefaultPath: default path: " << mPsDefault->getJson(); return bDefault; } @@ -173,7 +171,7 @@ Pathfinder::Pathfinder(RLCache::ref cache, LedgerEntrySet lesActive(mLedger, tapNONE); - cLog(lsTRACE) << boost::str(boost::format("Pathfinder> mSrcAmount=%s mDstAmount=%s") + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("Pathfinder> mSrcAmount=%s mDstAmount=%s") % mSrcAmount.getFullText() % mDstAmount.getFullText()); @@ -182,14 +180,14 @@ Pathfinder::Pathfinder(RLCache::ref cache, if (tesSUCCESS == psDefault->terStatus) { // The default path works, remember it. - cLog(lsTRACE) << "Pathfinder: default path: " << psDefault->getJson(); + WriteLog (lsTRACE, Pathfinder) << "Pathfinder: default path: " << psDefault->getJson(); mPsDefault = psDefault; } else { // The default path doesn't work. - cLog(lsTRACE) << "Pathfinder: default path: NONE: " << transToken(psDefault->terStatus); + WriteLog (lsTRACE, Pathfinder) << "Pathfinder: default path: NONE: " << transToken(psDefault->terStatus); } } } @@ -212,7 +210,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax { bool bFound = false; // True, iff found a path. - cLog(lsTRACE) << boost::str(boost::format("findPaths> mSrcAccountID=%s mDstAccountID=%s mDstAmount=%s mSrcCurrencyID=%s mSrcIssuerID=%s") + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths> mSrcAccountID=%s mDstAccountID=%s mDstAmount=%s mSrcCurrencyID=%s mSrcIssuerID=%s") % RippleAddress::createHumanAccountID(mSrcAccountID) % RippleAddress::createHumanAccountID(mDstAccountID) % mDstAmount.getFullText() @@ -222,7 +220,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax if (!mLedger) { - cLog(lsDEBUG) << "findPaths< no ledger"; + WriteLog (lsDEBUG, Pathfinder) << "findPaths< no ledger"; return false; } @@ -233,7 +231,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID)); if (!sleSrc) { - cLog(lsDEBUG) << boost::str(boost::format("findPaths< no source")); + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths< no source")); return false; } @@ -241,7 +239,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax SLE::pointer sleDst = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mDstAccountID)); if (!sleDst) { - cLog(lsDEBUG) << boost::str(boost::format("findPaths< no dest")); + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths< no dest")); return false; } @@ -297,35 +295,35 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax if (spPath.size()) { // There is an actual path element. - cLog(lsTRACE) << "findPaths: adding path: " << spPath.getJson(0); + WriteLog (lsTRACE, Pathfinder) << "findPaths: adding path: " << spPath.getJson(0); vspResults.push_back(spPath); // Potential result. } else { - cLog(lsWARNING) << "findPaths: empty path: XRP->XRP"; + WriteLog (lsWARNING, Pathfinder) << "findPaths: empty path: XRP->XRP"; } continue; } - if (sLog(lsTRACE)) + if (ShouldLog (lsTRACE, Pathfinder)) { - cLog(lsTRACE) << boost::str(boost::format("findPaths: spe: %s/%s: %s amt: %s") + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: spe: %s/%s: %s amt: %s") % RippleAddress::createHumanAccountID(speEnd.mAccountID) % RippleAddress::createHumanAccountID(speEnd.mIssuerID) % RippleAddress::createHumanAccountID(mDstAccountID) % RippleAddress::createHumanAccountID(mDstAmount.getIssuer())); - cLog(lsTRACE) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID); - cLog(lsTRACE) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency()); - cLog(lsTRACE) << "findPaths: finish? issuer: " + WriteLog (lsTRACE, Pathfinder) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID); + WriteLog (lsTRACE, Pathfinder) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency()); + WriteLog (lsTRACE, Pathfinder) << "findPaths: finish? issuer: " << RippleAddress::createHumanAccountID(speEnd.mIssuerID) << " / " << RippleAddress::createHumanAccountID(mDstAmount.getIssuer()) << " / " << RippleAddress::createHumanAccountID(mDstAccountID); - cLog(lsTRACE) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer()); + WriteLog (lsTRACE, Pathfinder) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer()); } // YYY Allows going through self. Is this wanted? @@ -339,7 +337,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax // Cursor on the dest account with correct currency and issuer. if (bDefaultPath(spPath)) { - cLog(lsTRACE) << "findPaths: dropping: default path: " << spPath.getJson(0); + WriteLog (lsTRACE, Pathfinder) << "findPaths: dropping: default path: " << spPath.getJson(0); bFound = true; } @@ -358,7 +356,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax vspResults.push_back(spPath); // Potential result. - cLog(lsDEBUG) << "findPaths: adding path: " << spPath.getJson(0); + WriteLog (lsDEBUG, Pathfinder) << "findPaths: adding path: " << spPath.getJson(0); } continue; @@ -366,7 +364,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax bool bContinued = false; // True, if wasn't a dead end. - cLog(lsTRACE) << + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: cursor: %s - %s/%s") % RippleAddress::createHumanAccountID(speEnd.mAccountID) % STAmount::createHumanCurrency(speEnd.mCurrencyID) @@ -377,7 +375,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax { // Path is at maximum size. Don't want to add more. - cLog(lsTRACE) + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: dropping: path would exceed max steps")); continue; @@ -407,7 +405,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax spNew.mPath.push_back(speBook); // Add the order book. spNew.mPath.push_back(speAccount); // Add the account and currency - cLog(lsDEBUG) + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: XRP -> %s/%s") // % STAmount::createHumanCurrency(book->getCurrencyOut()) // % RippleAddress::createHumanAccountID(book->getIssuerOut()) @@ -420,7 +418,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } } - tLog(!bContinued, lsDEBUG) + CondLog (!bContinued, lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: XRP -> dead end")); } else @@ -431,7 +429,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID)); - tLog(!sleEnd, lsDEBUG) + CondLog (!sleEnd, lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: tail: %s/%s : ") % RippleAddress::createHumanAccountID(speEnd.mAccountID) % RippleAddress::createHumanAccountID(speEnd.mIssuerID)); @@ -462,7 +460,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax ((uPeerID == mSrcAccountID) && (uPeerID != mDstAccountID))) { // Peer is in path already. Ignore it to avoid a loop. - cLog(lsTRACE) << + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: SEEN: %s/%s -> %s/%s") % RippleAddress::createHumanAccountID(speEnd.mAccountID) % STAmount::createHumanCurrency(speEnd.mCurrencyID) @@ -479,7 +477,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax || (bRequireAuth && !rspEntry->getAuth()))) // Not authorized to hold credit. { // Path has no credit left. Ignore it. - cLog(lsTRACE) << + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: No credit: %s/%s -> %s/%s balance=%s limit=%s") % RippleAddress::createHumanAccountID(speEnd.mAccountID) % STAmount::createHumanCurrency(speEnd.mCurrencyID) @@ -523,7 +521,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax bContinued = true; - cLog(lsTRACE) << + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: push explore: %s/%s -> %s/%s") % STAmount::createHumanCurrency(speEnd.mCurrencyID) % RippleAddress::createHumanAccountID(speEnd.mAccountID) @@ -565,7 +563,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax bContinued = true; - cLog(lsTRACE) << + WriteLog (lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: push book: %s/%s -> %s/%s") % STAmount::createHumanCurrency(speEnd.mCurrencyID) % RippleAddress::createHumanAccountID(speEnd.mIssuerID) @@ -574,7 +572,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } } - tLog(!bContinued, lsTRACE) + CondLog (!bContinued, lsTRACE, Pathfinder) << boost::str(boost::format("findPaths: dropping: non-XRP -> dead end")); } } @@ -619,7 +617,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } catch (const std::exception& e) { - cLog(lsINFO) << "findPaths: Caught throw: " << e.what(); + WriteLog (lsINFO, Pathfinder) << "findPaths: Caught throw: " << e.what(); terResult = tefEXCEPTION; } @@ -628,7 +626,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax { uint64 uQuality = STAmount::getRate(saDstAmountAct, saMaxAmountAct); - cLog(lsDEBUG) + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: quality: %d: %s") % uQuality % spCurrent.getJson(0)); @@ -637,7 +635,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } else { - cLog(lsDEBUG) + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: dropping: %s: %s") % transToken(terResult) % spCurrent.getJson(0)); @@ -674,17 +672,17 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax if (tesSUCCESS == result) { - cLog(lsDEBUG) << "Default path contributes: " << saDstAmountAct; + WriteLog (lsDEBUG, Pathfinder) << "Default path contributes: " << saDstAmountAct; remaining -= saDstAmountAct; } else { - cLog(lsDEBUG) << "Default path fails: " << transToken(result); + WriteLog (lsDEBUG, Pathfinder) << "Default path fails: " << transToken(result); } } catch (...) { - cLog(lsDEBUG) << "Default path causes exception"; + WriteLog (lsDEBUG, Pathfinder) << "Default path causes exception"; } } @@ -698,26 +696,26 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax spsDst.addPath(vspResults[lqt.get<3>()]); } else - cLog(lsDEBUG) << "Skipping a non-filling path: " << vspResults[lqt.get<3>()].getJson(0); + WriteLog (lsDEBUG, Pathfinder) << "Skipping a non-filling path: " << vspResults[lqt.get<3>()].getJson(0); } if (remaining.isPositive()) { bFound = false; - cLog(lsINFO) << "Paths could not send " << remaining << " of " << mDstAmount; + WriteLog (lsINFO, Pathfinder) << "Paths could not send " << remaining << " of " << mDstAmount; } else bFound = true; - cLog(lsDEBUG) << boost::str(boost::format("findPaths: RESULTS: %s") % spsDst.getJson(0)); + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: RESULTS: %s") % spsDst.getJson(0)); } else { - cLog(lsDEBUG) << boost::str(boost::format("findPaths: RESULTS: non-defaults filtered away")); + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths: RESULTS: non-defaults filtered away")); } } - cLog(lsDEBUG) << boost::str(boost::format("findPaths< bFound=%d") % bFound); + WriteLog (lsDEBUG, Pathfinder) << boost::str(boost::format("findPaths< bFound=%d") % bFound); return bFound; } diff --git a/src/cpp/ripple/RippleAddress.cpp b/src/cpp/ripple/RippleAddress.cpp index 4c01574225..2608428b88 100644 --- a/src/cpp/ripple/RippleAddress.cpp +++ b/src/cpp/ripple/RippleAddress.cpp @@ -21,8 +21,6 @@ #include "Serializer.h" #include "Application.h" -SETUP_LOG(); - std::size_t hash_value(const CBase58Data& b58) { std::size_t seed = theApp->getNonceST() + (b58.nVersion * 0x9e3779b9); @@ -424,7 +422,7 @@ bool RippleAddress::accountPublicVerify(const uint256& uHash, const std::vector< if (!ckPublic.SetPubKey(getAccountPublic())) { // Bad private key. - cLog(lsWARNING) << "accountPublicVerify: Bad private key."; + WriteLog (lsWARNING, RippleAddress) << "accountPublicVerify: Bad private key."; bVerified = false; } else @@ -525,13 +523,13 @@ bool RippleAddress::accountPrivateSign(const uint256& uHash, std::vector RippleAddress::accountPrivateEncrypt(const RippleAddr if (!ckPublic.SetPubKey(naPublicTo.getAccountPublic())) { // Bad public key. - cLog(lsWARNING) << "accountPrivateEncrypt: Bad public key."; + WriteLog (lsWARNING, RippleAddress) << "accountPrivateEncrypt: Bad public key."; } else if (!ckPrivate.SetPrivateKeyU(getAccountPrivate())) { // Bad private key. - cLog(lsWARNING) << "accountPrivateEncrypt: Bad private key."; + WriteLog (lsWARNING, RippleAddress) << "accountPrivateEncrypt: Bad private key."; } else { @@ -598,12 +596,12 @@ std::vector RippleAddress::accountPrivateDecrypt(const RippleAddr if (!ckPublic.SetPubKey(naPublicFrom.getAccountPublic())) { // Bad public key. - cLog(lsWARNING) << "accountPrivateDecrypt: Bad public key."; + WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad public key."; } else if (!ckPrivate.SetPrivateKeyU(getAccountPrivate())) { // Bad private key. - cLog(lsWARNING) << "accountPrivateDecrypt: Bad private key."; + WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad private key."; } else {