Compare commits

..

7 Commits

Author SHA1 Message Date
Vinnie Falco
95f31b98a8 Set version to 0.26.4-sp2 2014-11-11 14:22:37 -08:00
Miguel Portilla
10d74ed100 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.
2014-11-11 14:21:49 -08:00
Vinnie Falco
8a7f612d5b Revert pathfinding changes:
* 5e7c527 Revert "Fix account_lines, account_offers and book_offers result (RIPD-682):"
* b3417ca Revert "Fix pathfinding with multiple issuers for one currency (RIPD-618)."
* 00db7f5 Revert "Clean up Pathfinder."
2014-11-11 14:21:40 -08:00
Miguel Portilla
a46ae4efec Set version to 0.26.4-sp1 2014-11-10 16:25:45 -05:00
Miguel Portilla
62777a794e 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.
2014-11-10 16:25:14 -05:00
Tom Ritchford
bb44bdd047 Fix pathfinding with multiple issuers for one currency (RIPD-618).
* Allow pathfinding requests where the starting currency may have
  multiple issuers.

* Cache paths over all issuers to avoid repeating work.

* Clear the ledger checkpoint in one retry case.

* Add an additional node at the front of paths when the starting issuer
  is not the source account.
2014-11-10 12:07:57 -05:00
Tom Ritchford
6904e66384 Clean up Pathfinder.
* Restrict to 80-columns and other style cleanups.
* Make pathfinding a free function and hide the class Pathfinder.
* Split off unrelated utility functions into separate files.
2014-11-10 12:06:49 -05:00
8 changed files with 81 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
Name: rippled
Version: 0.26.4
Version: 0.26.4-sp2
Release: 1%{?dist}
Summary: Ripple peer-to-peer network daemon

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();

View File

@@ -187,6 +187,7 @@ public:
//
virtual void getBookPage (
bool bAdmin,
Ledger::pointer lpLedger,
Book const& book,
Account const& uTakerID,

View File

@@ -33,7 +33,7 @@ char const* getRawVersionString ()
//
// The build version number (edit this for each release)
//
"0.26.4"
"0.26.4-sp2"
//
// Must follow the format described here:
//

View File

@@ -74,27 +74,29 @@ void addLine (Json::Value& jsonLines, RippleState const& line)
// }
Json::Value doAccountLines (RPC::Context& context)
{
auto& params = context.params_;
auto const& params (context.params_);
if (! params.isMember (jss::account))
return RPC::missing_field_error ("account");
Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_));
if (! ledger)
return result;
if (! params.isMember (jss::account))
return RPC::missing_field_error ("account");
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
RippleAddress rippleAddress;
result = RPC::accountFromString (
ledger, rippleAddress, bIndex, strIdent, iIndex, false, context.netOps_);
Json::Value const jv (RPC::accountFromString (ledger, rippleAddress, bIndex,
strIdent, iIndex, false, context.netOps_));
if (! jv.empty ())
{
for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
if (! result.empty ())
return result;
}
if (! ledger->hasAccount (rippleAddress))
return rpcError (rpcACT_NOT_FOUND);
@@ -113,8 +115,8 @@ Json::Value doAccountLines (RPC::Context& context)
if (bPeerIndex)
result[jss::peer_index] = iPeerIndex;
result = RPC::accountFromString (ledger, rippleAddressPeer, bPeerIndex, strPeer,
iPeerIndex, false, context.netOps_);
result = RPC::accountFromString (ledger, rippleAddressPeer, bPeerIndex,
strPeer, iPeerIndex, false, context.netOps_);
if (! result.empty ())
return result;
@@ -127,9 +129,18 @@ Json::Value doAccountLines (RPC::Context& context)
unsigned int limit;
if (params.isMember (jss::limit))
{
limit = std::max (RPC::Tuning::minLinesPerRequest,
std::min (params[jss::limit].asUInt (),
RPC::Tuning::maxLinesPerRequest));
auto const& jvLimit (params[jss::limit]);
if (! jvLimit.isIntegral ())
return RPC::expected_field_error ("limit", "unsigned integer");
limit = jvLimit.isUInt () ? jvLimit.asUInt () :
std::max (0, jvLimit.asInt ());
if (context.role_ != Config::ADMIN)
{
limit = std::max (RPC::Tuning::minLinesPerRequest,
std::min (limit, RPC::Tuning::maxLinesPerRequest));
}
}
else
{
@@ -150,7 +161,7 @@ Json::Value doAccountLines (RPC::Context& context)
Json::Value const& marker (params[jss::marker]);
if (! marker.isString ())
return rpcError (rpcACT_MALFORMED);
return RPC::expected_field_error ("marker", "string");
startAfter.SetHex (marker.asString ());
SLE::pointer sleLine (ledger->getSLEi (startAfter));

View File

@@ -32,27 +32,28 @@ namespace ripple {
Json::Value doAccountOffers (RPC::Context& context)
{
auto const& params (context.params_);
if (! params.isMember (jss::account))
return RPC::missing_field_error ("account");
Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_));
if (! ledger)
return result;
if (! params.isMember (jss::account))
return RPC::missing_field_error ("account");
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int const iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
RippleAddress rippleAddress;
result = RPC::accountFromString (ledger, rippleAddress, bIndex, strIdent,
iIndex, false, context.netOps_);
Json::Value const jv (RPC::accountFromString (ledger, rippleAddress, bIndex,
strIdent, iIndex, false, context.netOps_));
if (! jv.empty ())
{
for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
if (! result.empty ())
return result;
}
// Get info on account.
result[jss::account] = rippleAddress.humanAccountID ();
@@ -66,9 +67,18 @@ Json::Value doAccountOffers (RPC::Context& context)
unsigned int limit;
if (params.isMember (jss::limit))
{
limit = std::max (RPC::Tuning::minOffersPerRequest,
std::min (params[jss::limit].asUInt (),
RPC::Tuning::maxOffersPerRequest));
auto const& jvLimit (params[jss::limit]);
if (! jvLimit.isIntegral ())
return RPC::expected_field_error ("limit", "unsigned integer");
limit = jvLimit.isUInt () ? jvLimit.asUInt () :
std::max (0, jvLimit.asInt ());
if (context.role_ != Config::ADMIN)
{
limit = std::max (RPC::Tuning::minOffersPerRequest,
std::min (limit, RPC::Tuning::maxOffersPerRequest));
}
}
else
{
@@ -89,7 +99,7 @@ Json::Value doAccountOffers (RPC::Context& context)
Json::Value const& marker (params[jss::marker]);
if (! marker.isString ())
return rpcError (rpcACT_MALFORMED);
return RPC::expected_field_error ("marker", "string");
startAfter.SetHex (marker.asString ());
SLE::pointer sleOffer (ledger->getSLEi (startAfter));

View File

@@ -162,15 +162,21 @@ Json::Value doBookOffers (RPC::Context& context)
return RPC::make_error (rpcBAD_MARKET);
}
if (context.params_.isMember ("limit") &&
!context.params_ ["limit"].isIntegral())
unsigned int iLimit;
if (context.params_.isMember (jss::limit))
{
return RPC::expected_field_error ("limit", "integer");
}
auto const& jvLimit (context.params_[jss::limit]);
unsigned int const iLimit (context.params_.isMember ("limit")
? context.params_ ["limit"].asUInt ()
: 0);
if (! jvLimit.isIntegral ())
return RPC::expected_field_error ("limit", "unsigned integer");
iLimit = jvLimit.isUInt () ? jvLimit.asUInt () :
std::max (0, jvLimit.asInt ());
}
else
{
iLimit = 0;
}
bool const bProof (context.params_.isMember ("proof"));
@@ -179,6 +185,7 @@ Json::Value doBookOffers (RPC::Context& context)
: Json::Value (Json::nullValue));
context.netOps_.getBookPage (
context.role_ == Config::ADMIN,
lpLedger,
{{pay_currency, pay_issuer}, {get_currency, get_issuer}},
raTakerID.getAccountID (), bProof, iLimit, jvMarker, jvResult);

View File

@@ -309,6 +309,7 @@ Json::Value doSubscribe (RPC::Context& context)
Json::Value jvAsks (Json::objectValue);
context.netOps_.getBookPage (
context.role_ == Config::ADMIN,
lpLedger, book, raTakerID.getAccountID (), false, 0,
jvMarker, jvBids);
@@ -316,6 +317,7 @@ Json::Value doSubscribe (RPC::Context& context)
jvResult[jss::bids] = jvBids[jss::offers];
context.netOps_.getBookPage (
context.role_ == Config::ADMIN,
lpLedger, book, raTakerID.getAccountID (),
false, 0, jvMarker, jvAsks);
@@ -325,6 +327,7 @@ Json::Value doSubscribe (RPC::Context& context)
else
{
context.netOps_.getBookPage (
context.role_ == Config::ADMIN,
lpLedger, book, raTakerID.getAccountID (), false, 0,
jvMarker, jvResult);
}