Fix RPC ripple_lines_get to return multiple lines for peer account.

This commit is contained in:
Arthur Britto
2012-07-10 15:19:39 -07:00
parent 93089186e1
commit db7cf11312

View File

@@ -1082,7 +1082,7 @@ Json::Value RPCServer::doRippleLinesGet(const Json::Value &params)
AccountState::pointer as = mNetOps->getAccountState(uCurrent, naAccount); AccountState::pointer as = mNetOps->getAccountState(uCurrent, naAccount);
if (as) if (as)
{ {
Json::Value jsonLines = Json::Value(Json::objectValue); Json::Value jsonLines(Json::arrayValue);
ret["account"] = naAccount.humanAccountID(); ret["account"] = naAccount.humanAccountID();
@@ -1107,11 +1107,6 @@ Json::Value RPCServer::doRippleLinesGet(const Json::Value &params)
BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue()) BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue())
{ {
NewcoinAddress naAccountPeer;
STAmount saBalance;
STAmount saLimit;
STAmount saLimitPeer;
Log(lsINFO) << "doRippleLinesGet: line index: " << uNode.ToString(); Log(lsINFO) << "doRippleLinesGet: line index: " << uNode.ToString();
RippleState::pointer rsLine = mNetOps->getRippleState(uCurrent, uNode); RippleState::pointer rsLine = mNetOps->getRippleState(uCurrent, uNode);
@@ -1120,21 +1115,21 @@ Json::Value RPCServer::doRippleLinesGet(const Json::Value &params)
{ {
rsLine->setViewAccount(naAccount); rsLine->setViewAccount(naAccount);
naAccountPeer = rsLine->getAccountIDPeer(); STAmount saBalance = rsLine->getBalance();
saBalance = rsLine->getBalance(); STAmount saLimit = rsLine->getLimit();
saLimit = rsLine->getLimit(); STAmount saLimitPeer = rsLine->getLimitPeer();
saLimitPeer = rsLine->getLimitPeer();
Json::Value jPeer = Json::Value(Json::objectValue); Json::Value jPeer = Json::Value(Json::objectValue);
jPeer["node"] = uNode.ToString(); jPeer["node"] = uNode.ToString();
jPeer["account"] = rsLine->getAccountIDPeer().humanAccountID();
jPeer["balance"] = saBalance.getText(); jPeer["balance"] = saBalance.getText();
jPeer["currency"] = saBalance.getCurrencyHuman(); jPeer["currency"] = saBalance.getCurrencyHuman();
jPeer["limit"] = saLimit.getJson(0); jPeer["limit"] = saLimit.getJson(0);
jPeer["limit_peer"] = saLimitPeer.getJson(0); jPeer["limit_peer"] = saLimitPeer.getJson(0);
jsonLines[naAccountPeer.humanAccountID()] = jPeer; jsonLines.append(jPeer);
} }
else else
{ {