diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index bb29edacc..c85a5fa31 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -129,7 +129,7 @@ bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second) Pathfinder::Pathfinder(Ledger::ref ledger, const RippleAddress& uSrcAccountID, const RippleAddress& uDstAccountID, - const uint160& uSrcCurrencyID, const uint160& uSrcIssuerID, const STAmount& saDstAmount) + const uint160& uSrcCurrencyID, const uint160& uSrcIssuerID, const STAmount& saDstAmount, bool bValid) : mSrcAccountID(uSrcAccountID.getAccountID()), mDstAccountID(uDstAccountID.getAccountID()), mDstAmount(saDstAmount), @@ -139,6 +139,13 @@ Pathfinder::Pathfinder(Ledger::ref ledger, mLedger(ledger) { + if ((mSrcAccountID == mDstAccountID) && (mSrcCurrencyID == mDstAmount.getCurrency())) + { // no need to send to same account with same currency + bValid = false; + return; + } + bValid = true; + theApp->getOrderBookDB().setup(mLedger); mLoadMonitor = theApp->getJobQueue().getLoadEvent(jtPATH_FIND, "FindPath"); diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index 3de0b3c0a..bdab7af5b 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -71,7 +71,7 @@ class Pathfinder public: Pathfinder(Ledger::ref ledger, const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, - const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount); + const uint160& srcCurrencyID, const uint160& srcIssuerID, const STAmount& dstAmount, bool bValid); bool findPaths(const unsigned int iMaxSteps, const unsigned int iMaxPaths, STPathSet& spsDst); diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index b43a10ae0..d779c10b4 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -178,10 +178,11 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) boost::ref(*mNetOps->getCurrentLedger()), false); { ScopedUnlock su(theApp->getMasterLock()); + bool bValid; Pathfinder pf(lSnapshot, raSrcAddressID, dstAccountID, - saSendMax.getCurrency(), saSendMax.getIssuer(), saSend); + saSendMax.getCurrency(), saSendMax.getIssuer(), saSend, bValid); - if (!pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsPaths)) + if (!bValid || !pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsPaths)) { cLog(lsDEBUG) << "transactionSign: build_path: No paths found."; @@ -1272,9 +1273,10 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost) } STPathSet spsComputed; - Pathfinder pf(lSnapShot, raSrc, raDst, uSrcCurrencyID, uSrcIssuerID, saDstAmount); + bool bValid; + Pathfinder pf(lSnapShot, raSrc, raDst, uSrcCurrencyID, uSrcIssuerID, saDstAmount, bValid); - if (!pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsComputed)) + if (!bValid || !pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsComputed)) { cLog(lsWARNING) << "ripple_path_find: No paths found."; }