Merge branch 'develop' of github.com:jedmccaleb/NewCoin into develop

This commit is contained in:
Arthur Britto
2013-04-09 22:13:15 -07:00
3 changed files with 38 additions and 1 deletions

View File

@@ -714,7 +714,7 @@ boost::unordered_set<uint160> usAccountSourceCurrencies(const RippleAddress& raA
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
{
RippleState* rspEntry = (RippleState*) item.get();
STAmount saBalance = rspEntry->getBalance();
const STAmount& saBalance = rspEntry->getBalance();
// Filter out non
if (saBalance.isPositive() // Have IOUs to send.
@@ -729,6 +729,30 @@ boost::unordered_set<uint160> usAccountSourceCurrencies(const RippleAddress& raA
return usCurrencies;
}
boost::unordered_set<uint160> usAccountDestCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger,
bool includeXRP)
{
boost::unordered_set<uint160> usCurrencies;
if (includeXRP)
usCurrencies.insert(uint160(CURRENCY_XRP)); // Even if account doesn't exist
// List of ripple lines.
AccountItems rippleLines(raAccountID.getAccountID(), lrLedger, AccountItem::pointer(new RippleState()));
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
{
RippleState* rspEntry = (RippleState*) item.get();
const STAmount& saBalance = rspEntry->getBalance();
if (saBalance < rspEntry->getLimit()) // Can take more
usCurrencies.insert(saBalance.getCurrency());
}
usCurrencies.erase(CURRENCY_BAD);
return usCurrencies;
}
AccountItems& Pathfinder::getRippleLines(const uint160& accountID)
{
boost::unordered_map<uint160, AccountItems::pointer>::iterator it = mRLMap.find(accountID);

View File

@@ -78,8 +78,12 @@ public:
bool bDefaultPath(const STPath& spPath);
};
boost::unordered_set<uint160> usAccountDestCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger,
bool includeXRP);
boost::unordered_set<uint160> usAccountSourceCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger,
bool includeXRP);
#endif
// vim:ts=4

View File

@@ -1234,6 +1234,15 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost)
ScopedUnlock su(theApp->getMasterLock()); // As long as we have a locked copy of the ledger, we can unlock.
// Fill in currencies destination will accept
Json::Value jvDestCur(Json::arrayValue);
boost::unordered_set<uint160> usDestCurrID = usAccountDestCurrencies(raDst, lpLedger, true);
BOOST_FOREACH(const uint160& uCurrency, usDestCurrID)
jvDestCur.append(STAmount::createHumanCurrency(uCurrency));
jvResult["destination_currencies"] = jvDestCur;
Json::Value jvArray(Json::arrayValue);
for (unsigned int i=0; i != jvSrcCurrencies.size(); ++i) {