Fix account_lines, account_offers and book_offers result (RIPD-682):

The RPC account_lines and account_offers commands respond with the correct ledger info. account_offers, account_lines and book_offers allow admins unlimited size on the limit param. Specifying a negative value on limit clamps to the minimum value allowed. Incorrect types for limit are correctly reported in the result.
This commit is contained in:
Miguel Portilla
2014-11-06 16:28:14 -05:00
committed by Vinnie Falco
parent 8a7f612d5b
commit 10d74ed100
6 changed files with 79 additions and 52 deletions

View File

@@ -243,13 +243,9 @@ public:
// Book functions
//
void getBookPage (Ledger::pointer lpLedger,
Book const&,
Account const& uTakerID,
const bool bProof,
const unsigned int iLimit,
Json::Value const& jvMarker,
Json::Value& jvResult);
void getBookPage (bool bAdmin, Ledger::pointer lpLedger, Book const&,
Account const& uTakerID, const bool bProof, const unsigned int iLimit,
Json::Value const& jvMarker, Json::Value& jvResult);
// ledger proposal/close functions
void processTrustedProposal (
@@ -3082,6 +3078,7 @@ InfoSub::pointer NetworkOPsImp::addRpcSub (
//
// FIXME : support iLimit.
void NetworkOPsImp::getBookPage (
bool bAdmin,
Ledger::pointer lpLedger,
Book const& book,
Account const& uTakerID,
@@ -3119,14 +3116,13 @@ void NetworkOPsImp::getBookPage (
unsigned int uBookEntry;
STAmount saDirRate;
unsigned int iLeft = iLimit;
if (iLeft == 0 || iLeft > 300)
iLeft = 300;
auto uTransferRate = rippleTransferRate (lesActive, book.out.account);
while (! bDone && iLeft-- > 0)
unsigned int left (iLimit == 0 ? 300 : iLimit);
if (! bAdmin && left > 300)
left = 300;
while (!bDone && left-- > 0)
{
if (bDirectAdvance)
{
@@ -3300,6 +3296,7 @@ void NetworkOPsImp::getBookPage (
// FIXME : support iLimit.
void NetworkOPsImp::getBookPage (
bool bAdmin,
Ledger::pointer lpLedger,
Book const& book,
Account const& uTakerID,
@@ -3315,18 +3312,16 @@ void NetworkOPsImp::getBookPage (
LedgerEntrySet lesActive (lpLedger, tapNONE, true);
OrderBookIterator obIterator (lesActive, book);
unsigned int iLeft = iLimit;
if (iLeft == 0 || iLeft > 300)
iLeft = 300;
auto uTransferRate = rippleTransferRate (lesActive, book.out.account);
const bool bGlobalFreeze = lesActive.isGlobalFrozen (book.out.account) ||
lesActive.isGlobalFrozen (book.in.account);
unsigned int left (iLimit == 0 ? 300 : iLimit);
if (! bAdmin && left > 300)
left = 300;
while (iLeft-- > 0 && obIterator.nextOffer ())
while (left-- > 0 && obIterator.nextOffer ())
{
SLE::pointer sleOffer = obIterator.getCurrentOffer();