Fix public member names of RPC::Context.

Conflicts:
	src/ripple/rpc/handlers/AccountTx.cpp
	src/ripple/rpc/handlers/AccountTxOld.cpp
	src/ripple/rpc/handlers/Ledger.cpp
	src/ripple/rpc/handlers/LedgerData.cpp
	src/ripple/rpc/handlers/RipplePathFind.cpp
	src/ripple/rpc/handlers/ServerInfo.cpp
	src/ripple/rpc/handlers/ServerState.cpp
	src/ripple/rpc/handlers/Submit.cpp
	src/ripple/rpc/handlers/Subscribe.cpp
	src/ripple/rpc/handlers/TxHistory.cpp
	src/ripple/rpc/handlers/Unsubscribe.cpp
	src/ripple/rpc/impl/Context.h
This commit is contained in:
Tom Ritchford
2014-11-03 14:41:44 -05:00
committed by Vinnie Falco
parent 150a3810a8
commit b30b2a523f
50 changed files with 393 additions and 383 deletions

View File

@@ -24,11 +24,11 @@ namespace ripple {
Json::Value doAccountCurrencies (RPC::Context& context) Json::Value doAccountCurrencies (RPC::Context& context)
{ {
auto& params = context.params_; auto& params = context.params;
// Get the current ledger // Get the current ledger
Ledger::pointer ledger; Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_)); Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
if (!ledger) if (!ledger)
return result; return result;
@@ -50,7 +50,7 @@ Json::Value doAccountCurrencies (RPC::Context& context)
bool bIndex; // out param bool bIndex; // out param
RippleAddress naAccount; // out param RippleAddress naAccount; // out param
Json::Value jvAccepted (RPC::accountFromString ( Json::Value jvAccepted (RPC::accountFromString (
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_)); ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps));
if (!jvAccepted.empty ()) if (!jvAccepted.empty ())
return jvAccepted; return jvAccepted;

View File

@@ -31,10 +31,10 @@ namespace ripple {
// TODO(tom): what is that "default"? // TODO(tom): what is that "default"?
Json::Value doAccountInfo (RPC::Context& context) Json::Value doAccountInfo (RPC::Context& context)
{ {
auto& params = context.params_; auto& params = context.params;
Ledger::pointer ledger; Ledger::pointer ledger;
Json::Value result = RPC::lookupLedger (params, ledger, context.netOps_); Json::Value result = RPC::lookupLedger (params, ledger, context.netOps);
if (!ledger) if (!ledger)
return result; return result;
@@ -53,12 +53,12 @@ Json::Value doAccountInfo (RPC::Context& context)
// Get info on account. // Get info on account.
Json::Value jvAccepted = RPC::accountFromString ( Json::Value jvAccepted = RPC::accountFromString (
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_); ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps);
if (!jvAccepted.empty ()) if (!jvAccepted.empty ())
return jvAccepted; return jvAccepted;
auto asAccepted = context.netOps_.getAccountState (ledger, naAccount); auto asAccepted = context.netOps.getAccountState (ledger, naAccount);
if (asAccepted) if (asAccepted)
{ {

View File

@@ -74,10 +74,10 @@ void addLine (Json::Value& jsonLines, RippleState const& line)
// } // }
Json::Value doAccountLines (RPC::Context& context) Json::Value doAccountLines (RPC::Context& context)
{ {
auto& params = context.params_; auto& params = context.params;
Ledger::pointer ledger; Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_)); Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
if (! ledger) if (! ledger)
return result; return result;
@@ -91,7 +91,7 @@ Json::Value doAccountLines (RPC::Context& context)
RippleAddress rippleAddress; RippleAddress rippleAddress;
result = RPC::accountFromString ( result = RPC::accountFromString (
ledger, rippleAddress, bIndex, strIdent, iIndex, false, context.netOps_); ledger, rippleAddress, bIndex, strIdent, iIndex, false, context.netOps);
if (! result.empty ()) if (! result.empty ())
return result; return result;
@@ -114,7 +114,7 @@ Json::Value doAccountLines (RPC::Context& context)
result[jss::peer_index] = iPeerIndex; result[jss::peer_index] = iPeerIndex;
result = RPC::accountFromString (ledger, rippleAddressPeer, bPeerIndex, strPeer, result = RPC::accountFromString (ledger, rippleAddressPeer, bPeerIndex, strPeer,
iPeerIndex, false, context.netOps_); iPeerIndex, false, context.netOps);
if (! result.empty ()) if (! result.empty ())
return result; return result;
@@ -212,7 +212,7 @@ Json::Value doAccountLines (RPC::Context& context)
for (auto const& item : visitData.items) for (auto const& item : visitData.items)
addLine (jsonLines, *item.get ()); addLine (jsonLines, *item.get ());
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
return result; return result;
} }

View File

@@ -31,10 +31,10 @@ namespace ripple {
// } // }
Json::Value doAccountOffers (RPC::Context& context) Json::Value doAccountOffers (RPC::Context& context)
{ {
auto const& params (context.params_); auto const& params (context.params);
Ledger::pointer ledger; Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_)); Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
if (! ledger) if (! ledger)
return result; return result;
@@ -49,7 +49,7 @@ Json::Value doAccountOffers (RPC::Context& context)
RippleAddress rippleAddress; RippleAddress rippleAddress;
result = RPC::accountFromString (ledger, rippleAddress, bIndex, strIdent, result = RPC::accountFromString (ledger, rippleAddress, bIndex, strIdent,
iIndex, false, context.netOps_); iIndex, false, context.netOps);
if (! result.empty ()) if (! result.empty ())
return result; return result;
@@ -151,7 +151,7 @@ Json::Value doAccountOffers (RPC::Context& context)
obj[jss::flags] = offer->getFieldU32 (sfFlags); obj[jss::flags] = offer->getFieldU32 (sfFlags);
} }
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
return result; return result;
} }

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -31,7 +32,7 @@ namespace ripple {
// } // }
Json::Value doAccountTx (RPC::Context& context) Json::Value doAccountTx (RPC::Context& context)
{ {
auto& params = context.params_; auto& params = context.params;
RippleAddress raAccount; RippleAddress raAccount;
int limit = params.isMember (jss::limit) ? int limit = params.isMember (jss::limit) ?
@@ -42,7 +43,7 @@ Json::Value doAccountTx (RPC::Context& context)
std::uint32_t uLedgerMax; std::uint32_t uLedgerMax;
std::uint32_t uValidatedMin; std::uint32_t uValidatedMin;
std::uint32_t uValidatedMax; std::uint32_t uValidatedMax;
bool bValidated = context.netOps_.getValidatedRange ( bool bValidated = context.netOps.getValidatedRange (
uValidatedMin, uValidatedMax); uValidatedMin, uValidatedMax);
if (!bValidated) if (!bValidated)
@@ -57,7 +58,7 @@ Json::Value doAccountTx (RPC::Context& context)
if (!raAccount.setAccountID (params["account"].asString ())) if (!raAccount.setAccountID (params["account"].asString ()))
return rpcError (rpcACT_MALFORMED); return rpcError (rpcACT_MALFORMED);
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
if (params.isMember ("ledger_index_min") || if (params.isMember ("ledger_index_min") ||
params.isMember ("ledger_index_max")) params.isMember ("ledger_index_max"))
@@ -76,7 +77,7 @@ Json::Value doAccountTx (RPC::Context& context)
else else
{ {
Ledger::pointer l; Ledger::pointer l;
Json::Value ret = RPC::lookupLedger (params, l, context.netOps_); Json::Value ret = RPC::lookupLedger (params, l, context.netOps);
if (!l) if (!l)
return ret; return ret;
@@ -101,9 +102,9 @@ Json::Value doAccountTx (RPC::Context& context)
if (bBinary) if (bBinary)
{ {
auto txns = context.netOps_.getTxsAccountB ( auto txns = context.netOps.getTxsAccountB (
raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit,
context.role_ == Role::ADMIN); context.role == Role::ADMIN);
for (auto& it: txns) for (auto& it: txns)
{ {
@@ -122,9 +123,9 @@ Json::Value doAccountTx (RPC::Context& context)
} }
else else
{ {
auto txns = context.netOps_.getTxsAccount ( auto txns = context.netOps.getTxsAccount (
raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit,
context.role_ == Role::ADMIN); context.role == Role::ADMIN);
for (auto& it: txns) for (auto& it: txns)
{ {

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -34,55 +35,55 @@ Json::Value doAccountTxOld (RPC::Context& context)
{ {
RippleAddress raAccount; RippleAddress raAccount;
std::uint32_t offset std::uint32_t offset
= context.params_.isMember ("offset") = context.params.isMember ("offset")
? context.params_["offset"].asUInt () : 0; ? context.params["offset"].asUInt () : 0;
int limit = context.params_.isMember ("limit") int limit = context.params.isMember ("limit")
? context.params_["limit"].asUInt () : -1; ? context.params["limit"].asUInt () : -1;
bool bBinary = context.params_.isMember ("binary") bool bBinary = context.params.isMember ("binary")
&& context.params_["binary"].asBool (); && context.params["binary"].asBool ();
bool bDescending = context.params_.isMember ("descending") bool bDescending = context.params.isMember ("descending")
&& context.params_["descending"].asBool (); && context.params["descending"].asBool ();
bool bCount = context.params_.isMember ("count") bool bCount = context.params.isMember ("count")
&& context.params_["count"].asBool (); && context.params["count"].asBool ();
std::uint32_t uLedgerMin; std::uint32_t uLedgerMin;
std::uint32_t uLedgerMax; std::uint32_t uLedgerMax;
std::uint32_t uValidatedMin; std::uint32_t uValidatedMin;
std::uint32_t uValidatedMax; std::uint32_t uValidatedMax;
bool bValidated = context.netOps_.getValidatedRange ( bool bValidated = context.netOps.getValidatedRange (
uValidatedMin, uValidatedMax); uValidatedMin, uValidatedMax);
if (!context.params_.isMember ("account")) if (!context.params.isMember ("account"))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
if (!raAccount.setAccountID (context.params_["account"].asString ())) if (!raAccount.setAccountID (context.params["account"].asString ()))
return rpcError (rpcACT_MALFORMED); return rpcError (rpcACT_MALFORMED);
if (offset > 3000) if (offset > 3000)
return rpcError (rpcATX_DEPRECATED); return rpcError (rpcATX_DEPRECATED);
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
// DEPRECATED // DEPRECATED
if (context.params_.isMember ("ledger_min")) if (context.params.isMember ("ledger_min"))
{ {
context.params_["ledger_index_min"] = context.params_["ledger_min"]; context.params["ledger_index_min"] = context.params["ledger_min"];
bDescending = true; bDescending = true;
} }
// DEPRECATED // DEPRECATED
if (context.params_.isMember ("ledger_max")) if (context.params.isMember ("ledger_max"))
{ {
context.params_["ledger_index_max"] = context.params_["ledger_max"]; context.params["ledger_index_max"] = context.params["ledger_max"];
bDescending = true; bDescending = true;
} }
if (context.params_.isMember ("ledger_index_min") if (context.params.isMember ("ledger_index_min")
|| context.params_.isMember ("ledger_index_max")) || context.params.isMember ("ledger_index_max"))
{ {
std::int64_t iLedgerMin = context.params_.isMember ("ledger_index_min") std::int64_t iLedgerMin = context.params.isMember ("ledger_index_min")
? context.params_["ledger_index_min"].asInt () : -1; ? context.params["ledger_index_min"].asInt () : -1;
std::int64_t iLedgerMax = context.params_.isMember ("ledger_index_max") std::int64_t iLedgerMax = context.params.isMember ("ledger_index_max")
? context.params_["ledger_index_max"].asInt () : -1; ? context.params["ledger_index_max"].asInt () : -1;
if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1)) if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1))
{ {
@@ -101,7 +102,7 @@ Json::Value doAccountTxOld (RPC::Context& context)
else else
{ {
Ledger::pointer l; Ledger::pointer l;
Json::Value ret = RPC::lookupLedger (context.params_, l, context.netOps_); Json::Value ret = RPC::lookupLedger (context.params, l, context.netOps);
if (!l) if (!l)
return ret; return ret;
@@ -124,9 +125,9 @@ Json::Value doAccountTxOld (RPC::Context& context)
if (bBinary) if (bBinary)
{ {
auto txns = context.netOps_.getAccountTxsB ( auto txns = context.netOps.getAccountTxsB (
raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit,
context.role_ == Role::ADMIN); context.role == Role::ADMIN);
for (auto it = txns.begin (), end = txns.end (); it != end; ++it) for (auto it = txns.begin (), end = txns.end (); it != end; ++it)
{ {
@@ -146,9 +147,9 @@ Json::Value doAccountTxOld (RPC::Context& context)
} }
else else
{ {
auto txns = context.netOps_.getAccountTxs ( auto txns = context.netOps.getAccountTxs (
raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit,
context.role_ == Role::ADMIN); context.role == Role::ADMIN);
for (auto it = txns.begin (), end = txns.end (); it != end; ++it) for (auto it = txns.begin (), end = txns.end (); it != end; ++it)
{ {
@@ -187,7 +188,7 @@ Json::Value doAccountTxOld (RPC::Context& context)
if (bCount) if (bCount)
ret["count"] = count; ret["count"] = count;
if (context.params_.isMember ("limit")) if (context.params.isMember ("limit"))
ret["limit"] = limit; ret["limit"] = limit;

View File

@@ -22,11 +22,11 @@ namespace ripple {
// Temporary switching code until the old account_tx is removed // Temporary switching code until the old account_tx is removed
Json::Value doAccountTxSwitch (RPC::Context& context) Json::Value doAccountTxSwitch (RPC::Context& context)
{ {
if (context.params_.isMember("offset") || if (context.params.isMember("offset") ||
context.params_.isMember("count") || context.params.isMember("count") ||
context.params_.isMember("descending") || context.params.isMember("descending") ||
context.params_.isMember("ledger_max") || context.params.isMember("ledger_max") ||
context.params_.isMember("ledger_min")) context.params.isMember("ledger_min"))
{ {
return doAccountTxOld(context); return doAccountTxOld(context);
} }

View File

@@ -23,8 +23,8 @@ namespace ripple {
Json::Value doBlackList (RPC::Context& context) Json::Value doBlackList (RPC::Context& context)
{ {
auto& rm = getApp().getResourceManager(); auto& rm = getApp().getResourceManager();
if (context.params_.isMember("threshold")) if (context.params.isMember("threshold"))
return rm.getJson(context.params_["threshold"].asInt()); return rm.getJson(context.params["threshold"].asInt());
else else
return rm.getJson(); return rm.getJson();
} }

View File

@@ -29,24 +29,24 @@ Json::Value doBookOffers (RPC::Context& context)
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult ( Json::Value jvResult (
RPC::lookupLedger (context.params_, lpLedger, context.netOps_)); RPC::lookupLedger (context.params, lpLedger, context.netOps));
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
if (!context.params_.isMember ("taker_pays")) if (!context.params.isMember ("taker_pays"))
return RPC::missing_field_error ("taker_pays"); return RPC::missing_field_error ("taker_pays");
if (!context.params_.isMember ("taker_gets")) if (!context.params.isMember ("taker_gets"))
return RPC::missing_field_error ("taker_gets"); return RPC::missing_field_error ("taker_gets");
if (!context.params_["taker_pays"].isObject ()) if (!context.params["taker_pays"].isObject ())
return RPC::object_field_error ("taker_pays"); return RPC::object_field_error ("taker_pays");
if (!context.params_["taker_gets"].isObject ()) if (!context.params["taker_gets"].isObject ())
return RPC::object_field_error ("taker_gets"); return RPC::object_field_error ("taker_gets");
Json::Value const& taker_pays (context.params_["taker_pays"]); Json::Value const& taker_pays (context.params["taker_pays"]);
if (!taker_pays.isMember ("currency")) if (!taker_pays.isMember ("currency"))
return RPC::missing_field_error ("taker_pays.currency"); return RPC::missing_field_error ("taker_pays.currency");
@@ -54,7 +54,7 @@ Json::Value doBookOffers (RPC::Context& context)
if (! taker_pays ["currency"].isString ()) if (! taker_pays ["currency"].isString ())
return RPC::expected_field_error ("taker_pays.currency", "string"); return RPC::expected_field_error ("taker_pays.currency", "string");
Json::Value const& taker_gets = context.params_["taker_gets"]; Json::Value const& taker_gets = context.params["taker_gets"];
if (! taker_gets.isMember ("currency")) if (! taker_gets.isMember ("currency"))
return RPC::missing_field_error ("taker_gets.currency"); return RPC::missing_field_error ("taker_gets.currency");
@@ -143,12 +143,12 @@ Json::Value doBookOffers (RPC::Context& context)
RippleAddress raTakerID; RippleAddress raTakerID;
if (context.params_.isMember ("taker")) if (context.params.isMember ("taker"))
{ {
if (! context.params_ ["taker"].isString ()) if (! context.params ["taker"].isString ())
return RPC::expected_field_error ("taker", "string"); return RPC::expected_field_error ("taker", "string");
if (! raTakerID.setAccountID (context.params_ ["taker"].asString ())) if (! raTakerID.setAccountID (context.params ["taker"].asString ()))
return RPC::invalid_field_error ("taker"); return RPC::invalid_field_error ("taker");
} }
else else
@@ -162,28 +162,28 @@ Json::Value doBookOffers (RPC::Context& context)
return RPC::make_error (rpcBAD_MARKET); return RPC::make_error (rpcBAD_MARKET);
} }
if (context.params_.isMember ("limit") && if (context.params.isMember ("limit") &&
!context.params_ ["limit"].isIntegral()) !context.params ["limit"].isIntegral())
{ {
return RPC::expected_field_error ("limit", "integer"); return RPC::expected_field_error ("limit", "integer");
} }
unsigned int const iLimit (context.params_.isMember ("limit") unsigned int const iLimit (context.params.isMember ("limit")
? context.params_ ["limit"].asUInt () ? context.params ["limit"].asUInt ()
: 0); : 0);
bool const bProof (context.params_.isMember ("proof")); bool const bProof (context.params.isMember ("proof"));
Json::Value const jvMarker (context.params_.isMember ("marker") Json::Value const jvMarker (context.params.isMember ("marker")
? context.params_["marker"] ? context.params["marker"]
: Json::Value (Json::nullValue)); : Json::Value (Json::nullValue));
context.netOps_.getBookPage ( context.netOps.getBookPage (
lpLedger, lpLedger,
{{pay_currency, pay_issuer}, {get_currency, get_issuer}}, {{pay_currency, pay_issuer}, {get_currency, get_issuer}},
raTakerID.getAccountID (), bProof, iLimit, jvMarker, jvResult); raTakerID.getAccountID (), bProof, iLimit, jvMarker, jvResult);
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
return jvResult; return jvResult;
} }

View File

@@ -32,24 +32,24 @@ Json::Value doConnect (RPC::Context& context)
if (getConfig ().RUN_STANDALONE) if (getConfig ().RUN_STANDALONE)
return "cannot connect in standalone mode"; return "cannot connect in standalone mode";
if (!context.params_.isMember ("ip")) if (!context.params.isMember ("ip"))
return RPC::missing_field_error ("ip"); return RPC::missing_field_error ("ip");
if (context.params_.isMember ("port") && if (context.params.isMember ("port") &&
!context.params_["port"].isConvertibleTo (Json::intValue)) !context.params["port"].isConvertibleTo (Json::intValue))
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
int iPort; int iPort;
if(context.params_.isMember ("port")) if(context.params.isMember ("port"))
iPort = context.params_["port"].asInt (); iPort = context.params["port"].asInt ();
else else
iPort = 6561; iPort = 6561;
auto ip = beast::IP::Endpoint::from_string( auto ip = beast::IP::Endpoint::from_string(
context.params_["ip"].asString ()); context.params["ip"].asString ());
if (! is_unspecified (ip)) if (! is_unspecified (ip))
getApp().overlay ().connect (ip.at_port(iPort)); getApp().overlay ().connect (ip.at_port(iPort));

View File

@@ -25,7 +25,7 @@ Json::Value doConsensusInfo (RPC::Context& context)
{ {
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
ret["info"] = context.netOps_.getConsensusInfo (); ret["info"] = context.netOps.getConsensusInfo ();
} }
return ret; return ret;

View File

@@ -43,7 +43,7 @@ static void textTime (
Json::Value doFeature (RPC::Context& context) Json::Value doFeature (RPC::Context& context)
{ {
if (!context.params_.isMember ("feature")) if (!context.params.isMember ("feature"))
{ {
Json::Value jvReply = Json::objectValue; Json::Value jvReply = Json::objectValue;
jvReply["features"] = getApp().getAmendmentTable ().getJson(0); jvReply["features"] = getApp().getAmendmentTable ().getJson(0);
@@ -52,17 +52,17 @@ Json::Value doFeature (RPC::Context& context)
uint256 uFeature uint256 uFeature
= getApp().getAmendmentTable ().get( = getApp().getAmendmentTable ().get(
context.params_["feature"].asString()); context.params["feature"].asString());
if (uFeature.isZero ()) if (uFeature.isZero ())
{ {
uFeature.SetHex (context.params_["feature"].asString ()); uFeature.SetHex (context.params["feature"].asString ());
if (uFeature.isZero ()) if (uFeature.isZero ())
return rpcError (rpcBAD_FEATURE); return rpcError (rpcBAD_FEATURE);
} }
if (!context.params_.isMember ("vote")) if (!context.params.isMember ("vote"))
return getApp().getAmendmentTable ().getJson(uFeature); return getApp().getAmendmentTable ().getJson(uFeature);
// WRITEME // WRITEME

View File

@@ -24,13 +24,13 @@ Json::Value doFetchInfo (RPC::Context& context)
{ {
Json::Value ret (Json::objectValue); Json::Value ret (Json::objectValue);
if (context.params_.isMember("clear") && context.params_["clear"].asBool()) if (context.params.isMember("clear") && context.params["clear"].asBool())
{ {
context.netOps_.clearLedgerFetch(); context.netOps.clearLedgerFetch();
ret["clear"] = true; ret["clear"] = true;
} }
ret["info"] = context.netOps_.getLedgerFetchInfo(); ret["info"] = context.netOps.getLedgerFetchInfo();
return ret; return ret;
} }

View File

@@ -31,8 +31,8 @@ Json::Value doGetCounts (RPC::Context& context)
int minCount = 10; int minCount = 10;
if (context.params_.isMember ("min_count")) if (context.params.isMember ("min_count"))
minCount = context.params_["min_count"].asUInt (); minCount = context.params["min_count"].asUInt ();
auto objectCounts = CountedObjects::getInstance ().getCounts (minCount); auto objectCounts = CountedObjects::getInstance ().getCounts (minCount);

View File

@@ -26,11 +26,11 @@ RPC::InternalHandler* RPC::InternalHandler::headHandler = nullptr;
Json::Value doInternal (RPC::Context& context) Json::Value doInternal (RPC::Context& context)
{ {
// Used for debug or special-purpose RPC commands // Used for debug or special-purpose RPC commands
if (!context.params_.isMember ("internal_command")) if (!context.params.isMember ("internal_command"))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
auto name = context.params_["internal_command"].asString (); auto name = context.params["internal_command"].asString ();
auto params = context.params_["params"]; auto params = context.params["params"];
for (auto* h = RPC::InternalHandler::headHandler; h; ) for (auto* h = RPC::InternalHandler::headHandler; h; )
{ {

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include <ripple/core/LoadFeeTrack.h> #include <ripple/core/LoadFeeTrack.h>
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -28,9 +29,9 @@ namespace ripple {
// } // }
Json::Value doLedger (RPC::Context& context) Json::Value doLedger (RPC::Context& context)
{ {
if (!context.params_.isMember ("ledger") if (!context.params.isMember ("ledger")
&& !context.params_.isMember ("ledger_hash") && !context.params.isMember ("ledger_hash")
&& !context.params_.isMember ("ledger_index")) && !context.params.isMember ("ledger_index"))
{ {
Json::Value ret (Json::objectValue), current (Json::objectValue), Json::Value ret (Json::objectValue), current (Json::objectValue),
closed (Json::objectValue); closed (Json::objectValue);
@@ -46,19 +47,19 @@ Json::Value doLedger (RPC::Context& context)
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger ( Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_); context.params, lpLedger, context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
bool bFull = context.params_.isMember ("full") bool bFull = context.params.isMember ("full")
&& context.params_["full"].asBool (); && context.params["full"].asBool ();
bool bTransactions = context.params_.isMember ("transactions") bool bTransactions = context.params.isMember ("transactions")
&& context.params_["transactions"].asBool (); && context.params["transactions"].asBool ();
bool bAccounts = context.params_.isMember ("accounts") bool bAccounts = context.params.isMember ("accounts")
&& context.params_["accounts"].asBool (); && context.params["accounts"].asBool ();
bool bExpand = context.params_.isMember ("expand") bool bExpand = context.params.isMember ("expand")
&& context.params_["expand"].asBool (); && context.params["expand"].asBool ();
int iOptions = (bFull ? LEDGER_JSON_FULL : 0) int iOptions = (bFull ? LEDGER_JSON_FULL : 0)
| (bExpand ? LEDGER_JSON_EXPAND : 0) | (bExpand ? LEDGER_JSON_EXPAND : 0)
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0) | (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
@@ -67,7 +68,7 @@ Json::Value doLedger (RPC::Context& context)
if (bFull || bAccounts) if (bFull || bAccounts)
{ {
if (context.role_ != Role::ADMIN) if (context.role != Role::ADMIN)
{ {
// Until some sane way to get full ledgers has been implemented, // Until some sane way to get full ledgers has been implemented,
// disallow retrieving all state nodes. // disallow retrieving all state nodes.
@@ -75,12 +76,12 @@ Json::Value doLedger (RPC::Context& context)
} }
if (getApp().getFeeTrack().isLoadedLocal() && if (getApp().getFeeTrack().isLoadedLocal() &&
context.role_ != Role::ADMIN) context.role != Role::ADMIN)
{ {
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger"; WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
return rpcError(rpcTOO_BUSY); return rpcError(rpcTOO_BUSY);
} }
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
} }

View File

@@ -31,10 +31,10 @@ Json::Value doLedgerAccept (RPC::Context& context)
} }
else else
{ {
context.netOps_.acceptLedger (); context.netOps.acceptLedger ();
jvResult["ledger_current_index"] jvResult["ledger_current_index"]
= context.netOps_.getCurrentLedgerID (); = context.netOps.getCurrentLedgerID ();
} }
return jvResult; return jvResult;

View File

@@ -22,7 +22,7 @@ namespace ripple {
Json::Value doLedgerCleaner (RPC::Context& context) Json::Value doLedgerCleaner (RPC::Context& context)
{ {
getApp().getLedgerMaster().doLedgerCleaner (context.params_); getApp().getLedgerMaster().doLedgerCleaner (context.params);
return "Cleaner configured"; return "Cleaner configured";
} }

View File

@@ -22,10 +22,10 @@ namespace ripple {
Json::Value doLedgerClosed (RPC::Context& context) Json::Value doLedgerClosed (RPC::Context& context)
{ {
uint256 uLedger = context.netOps_.getClosedLedgerHash (); uint256 uLedger = context.netOps.getClosedLedgerHash ();
Json::Value jvResult; Json::Value jvResult;
jvResult["ledger_index"] = context.netOps_.getLedgerID (uLedger); jvResult["ledger_index"] = context.netOps.getLedgerID (uLedger);
jvResult["ledger_hash"] = to_string (uLedger); jvResult["ledger_hash"] = to_string (uLedger);
return jvResult; return jvResult;

View File

@@ -23,7 +23,7 @@ namespace ripple {
Json::Value doLedgerCurrent (RPC::Context& context) Json::Value doLedgerCurrent (RPC::Context& context)
{ {
Json::Value jvResult; Json::Value jvResult;
jvResult["ledger_current_index"] = context.netOps_.getCurrentLedgerID (); jvResult["ledger_current_index"] = context.netOps.getCurrentLedgerID ();
return jvResult; return jvResult;
} }

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -38,14 +39,14 @@ Json::Value doLedgerData (RPC::Context& context)
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger ( Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_); context.params, lpLedger, context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
uint256 resumePoint; uint256 resumePoint;
if (context.params_.isMember ("marker")) if (context.params.isMember ("marker"))
{ {
Json::Value const& jMarker = context.params_["marker"]; Json::Value const& jMarker = context.params["marker"];
if (!jMarker.isString ()) if (!jMarker.isString ())
return RPC::expected_field_error ("marker", "valid"); return RPC::expected_field_error ("marker", "valid");
if (!resumePoint.SetHex (jMarker.asString ())) if (!resumePoint.SetHex (jMarker.asString ()))
@@ -53,9 +54,9 @@ Json::Value doLedgerData (RPC::Context& context)
} }
bool isBinary = false; bool isBinary = false;
if (context.params_.isMember ("binary")) if (context.params.isMember ("binary"))
{ {
Json::Value const& jBinary = context.params_["binary"]; Json::Value const& jBinary = context.params["binary"];
if (!jBinary.isBool ()) if (!jBinary.isBool ())
return RPC::expected_field_error ("binary", "bool"); return RPC::expected_field_error ("binary", "bool");
isBinary = jBinary.asBool (); isBinary = jBinary.asBool ();
@@ -64,16 +65,16 @@ Json::Value doLedgerData (RPC::Context& context)
int limit = -1; int limit = -1;
int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH; int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH;
if (context.params_.isMember ("limit")) if (context.params.isMember ("limit"))
{ {
Json::Value const& jLimit = context.params_["limit"]; Json::Value const& jLimit = context.params["limit"];
if (!jLimit.isIntegral ()) if (!jLimit.isIntegral ())
return RPC::expected_field_error ("limit", "integer"); return RPC::expected_field_error ("limit", "integer");
limit = jLimit.asInt (); limit = jLimit.asInt ();
} }
if ((limit < 0) || ((limit > maxLimit) && (context.role_ != Role::ADMIN))) if ((limit < 0) || ((limit > maxLimit) && (context.role != Role::ADMIN)))
limit = maxLimit; limit = maxLimit;
Json::Value jvReply = Json::objectValue; Json::Value jvReply = Json::objectValue;

View File

@@ -29,7 +29,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
{ {
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger ( Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_); context.params, lpLedger, context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
@@ -37,18 +37,18 @@ Json::Value doLedgerEntry (RPC::Context& context)
uint256 uNodeIndex; uint256 uNodeIndex;
bool bNodeBinary = false; bool bNodeBinary = false;
if (context.params_.isMember ("index")) if (context.params.isMember ("index"))
{ {
// XXX Needs to provide proof. // XXX Needs to provide proof.
uNodeIndex.SetHex (context.params_["index"].asString ()); uNodeIndex.SetHex (context.params["index"].asString ());
bNodeBinary = true; bNodeBinary = true;
} }
else if (context.params_.isMember ("account_root")) else if (context.params.isMember ("account_root"))
{ {
RippleAddress naAccount; RippleAddress naAccount;
if (!naAccount.setAccountID ( if (!naAccount.setAccountID (
context.params_["account_root"].asString ()) context.params["account_root"].asString ())
|| !naAccount.getAccountID ()) || !naAccount.getAccountID ())
{ {
jvResult["error"] = "malformedAddress"; jvResult["error"] = "malformedAddress";
@@ -59,37 +59,37 @@ Json::Value doLedgerEntry (RPC::Context& context)
= Ledger::getAccountRootIndex (naAccount.getAccountID ()); = Ledger::getAccountRootIndex (naAccount.getAccountID ());
} }
} }
else if (context.params_.isMember ("directory")) else if (context.params.isMember ("directory"))
{ {
if (!context.params_["directory"].isObject ()) if (!context.params["directory"].isObject ())
{ {
uNodeIndex.SetHex (context.params_["directory"].asString ()); uNodeIndex.SetHex (context.params["directory"].asString ());
} }
else if (context.params_["directory"].isMember ("sub_index") else if (context.params["directory"].isMember ("sub_index")
&& !context.params_["directory"]["sub_index"].isIntegral ()) && !context.params["directory"]["sub_index"].isIntegral ())
{ {
jvResult["error"] = "malformedRequest"; jvResult["error"] = "malformedRequest";
} }
else else
{ {
std::uint64_t uSubIndex std::uint64_t uSubIndex
= context.params_["directory"].isMember ("sub_index") = context.params["directory"].isMember ("sub_index")
? context.params_["directory"]["sub_index"].asUInt () : 0; ? context.params["directory"]["sub_index"].asUInt () : 0;
if (context.params_["directory"].isMember ("dir_root")) if (context.params["directory"].isMember ("dir_root"))
{ {
uint256 uDirRoot; uint256 uDirRoot;
uDirRoot.SetHex (context.params_["dir_root"].asString ()); uDirRoot.SetHex (context.params["dir_root"].asString ());
uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex); uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex);
} }
else if (context.params_["directory"].isMember ("owner")) else if (context.params["directory"].isMember ("owner"))
{ {
RippleAddress naOwnerID; RippleAddress naOwnerID;
if (!naOwnerID.setAccountID ( if (!naOwnerID.setAccountID (
context.params_["directory"]["owner"].asString ())) context.params["directory"]["owner"].asString ()))
{ {
jvResult["error"] = "malformedAddress"; jvResult["error"] = "malformedAddress";
} }
@@ -107,20 +107,20 @@ Json::Value doLedgerEntry (RPC::Context& context)
} }
} }
} }
else if (context.params_.isMember ("generator")) else if (context.params.isMember ("generator"))
{ {
RippleAddress naGeneratorID; RippleAddress naGeneratorID;
if (!context.params_["generator"].isObject ()) if (!context.params["generator"].isObject ())
{ {
uNodeIndex.SetHex (context.params_["generator"].asString ()); uNodeIndex.SetHex (context.params["generator"].asString ());
} }
else if (!context.params_["generator"].isMember ("regular_seed")) else if (!context.params["generator"].isMember ("regular_seed"))
{ {
jvResult["error"] = "malformedRequest"; jvResult["error"] = "malformedRequest";
} }
else if (!naGeneratorID.setSeedGeneric ( else if (!naGeneratorID.setSeedGeneric (
context.params_["generator"]["regular_seed"].asString ())) context.params["generator"]["regular_seed"].asString ()))
{ {
jvResult["error"] = "malformedAddress"; jvResult["error"] = "malformedAddress";
} }
@@ -135,38 +135,38 @@ Json::Value doLedgerEntry (RPC::Context& context)
uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ()); uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ());
} }
} }
else if (context.params_.isMember ("offer")) else if (context.params.isMember ("offer"))
{ {
RippleAddress naAccountID; RippleAddress naAccountID;
if (!context.params_["offer"].isObject ()) if (!context.params["offer"].isObject ())
{ {
uNodeIndex.SetHex (context.params_["offer"].asString ()); uNodeIndex.SetHex (context.params["offer"].asString ());
} }
else if (!context.params_["offer"].isMember ("account") else if (!context.params["offer"].isMember ("account")
|| !context.params_["offer"].isMember ("seq") || !context.params["offer"].isMember ("seq")
|| !context.params_["offer"]["seq"].isIntegral ()) || !context.params["offer"]["seq"].isIntegral ())
{ {
jvResult["error"] = "malformedRequest"; jvResult["error"] = "malformedRequest";
} }
else if (!naAccountID.setAccountID ( else if (!naAccountID.setAccountID (
context.params_["offer"]["account"].asString ())) context.params["offer"]["account"].asString ()))
{ {
jvResult["error"] = "malformedAddress"; jvResult["error"] = "malformedAddress";
} }
else else
{ {
auto uSequence = context.params_["offer"]["seq"].asUInt (); auto uSequence = context.params["offer"]["seq"].asUInt ();
uNodeIndex = Ledger::getOfferIndex ( uNodeIndex = Ledger::getOfferIndex (
naAccountID.getAccountID (), uSequence); naAccountID.getAccountID (), uSequence);
} }
} }
else if (context.params_.isMember ("ripple_state")) else if (context.params.isMember ("ripple_state"))
{ {
RippleAddress naA; RippleAddress naA;
RippleAddress naB; RippleAddress naB;
Currency uCurrency; Currency uCurrency;
Json::Value jvRippleState = context.params_["ripple_state"]; Json::Value jvRippleState = context.params["ripple_state"];
if (!jvRippleState.isObject () if (!jvRippleState.isObject ()
|| !jvRippleState.isMember ("currency") || !jvRippleState.isMember ("currency")
@@ -206,10 +206,10 @@ Json::Value doLedgerEntry (RPC::Context& context)
if (uNodeIndex.isNonZero ()) if (uNodeIndex.isNonZero ())
{ {
auto sleNode = context.netOps_.getSLEi (lpLedger, uNodeIndex); auto sleNode = context.netOps.getSLEi (lpLedger, uNodeIndex);
if (context.params_.isMember("binary")) if (context.params.isMember("binary"))
bNodeBinary = context.params_["binary"].asBool(); bNodeBinary = context.params["binary"].asBool();
if (!sleNode) if (!sleNode)
{ {

View File

@@ -28,7 +28,7 @@ Json::Value doLedgerHeader (RPC::Context& context)
{ {
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger ( Json::Value jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_); context.params, lpLedger, context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;

View File

@@ -26,8 +26,8 @@ namespace ripple {
// } // }
Json::Value doLedgerRequest (RPC::Context& context) Json::Value doLedgerRequest (RPC::Context& context)
{ {
auto const hasHash = context.params_.isMember (jss::ledger_hash); auto const hasHash = context.params.isMember (jss::ledger_hash);
auto const hasIndex = context.params_.isMember (jss::ledger_index); auto const hasIndex = context.params.isMember (jss::ledger_index);
auto& ledgerMaster = getApp().getLedgerMaster(); auto& ledgerMaster = getApp().getLedgerMaster();
LedgerHash ledgerHash; LedgerHash ledgerHash;
@@ -40,11 +40,11 @@ Json::Value doLedgerRequest (RPC::Context& context)
if (hasHash) if (hasHash)
{ {
auto const& jsonHash = context.params_[jss::ledger_hash]; auto const& jsonHash = context.params[jss::ledger_hash];
if (!jsonHash.isString() || !ledgerHash.SetHex (jsonHash.asString ())) if (!jsonHash.isString() || !ledgerHash.SetHex (jsonHash.asString ()))
return RPC::invalid_field_message ("ledger_hash"); return RPC::invalid_field_message ("ledger_hash");
} else { } else {
auto const& jsonIndex = context.params_[jss::ledger_index]; auto const& jsonIndex = context.params[jss::ledger_index];
if (!jsonIndex.isNumeric ()) if (!jsonIndex.isNumeric ())
return RPC::invalid_field_message ("ledger_index"); return RPC::invalid_field_message ("ledger_index");

View File

@@ -23,7 +23,7 @@ namespace ripple {
Json::Value doLogLevel (RPC::Context& context) Json::Value doLogLevel (RPC::Context& context)
{ {
// log_level // log_level
if (!context.params_.isMember ("severity")) if (!context.params.isMember ("severity"))
{ {
// get log severities // get log severities
Json::Value ret (Json::objectValue); Json::Value ret (Json::objectValue);
@@ -42,14 +42,14 @@ Json::Value doLogLevel (RPC::Context& context)
} }
LogSeverity const sv ( LogSeverity const sv (
Logs::fromString (context.params_["severity"].asString ())); Logs::fromString (context.params["severity"].asString ()));
if (sv == lsINVALID) if (sv == lsINVALID)
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
auto severity = Logs::toSeverity(sv); auto severity = Logs::toSeverity(sv);
// log_level severity // log_level severity
if (!context.params_.isMember ("partition")) if (!context.params.isMember ("partition"))
{ {
// set base log severity // set base log severity
deprecatedLogs().severity(severity); deprecatedLogs().severity(severity);
@@ -57,10 +57,10 @@ Json::Value doLogLevel (RPC::Context& context)
} }
// log_level partition severity base? // log_level partition severity base?
if (context.params_.isMember ("partition")) if (context.params.isMember ("partition"))
{ {
// set partition severity // set partition severity
std::string partition (context.params_["partition"].asString ()); std::string partition (context.params["partition"].asString ());
if (boost::iequals (partition, "base")) if (boost::iequals (partition, "base"))
deprecatedLogs().severity (severity); deprecatedLogs().severity (severity);

View File

@@ -27,24 +27,24 @@ namespace ripple {
Json::Value doOwnerInfo (RPC::Context& context) Json::Value doOwnerInfo (RPC::Context& context)
{ {
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
if (!context.params_.isMember ("account") && if (!context.params.isMember ("account") &&
!context.params_.isMember ("ident")) !context.params.isMember ("ident"))
{ {
return RPC::missing_field_error ("account"); return RPC::missing_field_error ("account");
} }
std::string strIdent = context.params_.isMember ("account") std::string strIdent = context.params.isMember ("account")
? context.params_["account"].asString () ? context.params["account"].asString ()
: context.params_["ident"].asString (); : context.params["ident"].asString ();
bool bIndex; bool bIndex;
int iIndex = context.params_.isMember ("account_index") int iIndex = context.params.isMember ("account_index")
? context.params_["account_index"].asUInt () : 0; ? context.params["account_index"].asUInt () : 0;
RippleAddress raAccount; RippleAddress raAccount;
Json::Value ret; Json::Value ret;
// Get info on account. // Get info on account.
auto const& closedLedger = context.netOps_.getClosedLedger (); auto const& closedLedger = context.netOps.getClosedLedger ();
Json::Value jAccepted = RPC::accountFromString ( Json::Value jAccepted = RPC::accountFromString (
closedLedger, closedLedger,
raAccount, raAccount,
@@ -52,12 +52,12 @@ Json::Value doOwnerInfo (RPC::Context& context)
strIdent, strIdent,
iIndex, iIndex,
false, false,
context.netOps_); context.netOps);
ret["accepted"] = jAccepted.empty () ? context.netOps_.getOwnerInfo ( ret["accepted"] = jAccepted.empty () ? context.netOps.getOwnerInfo (
closedLedger, raAccount) : jAccepted; closedLedger, raAccount) : jAccepted;
auto const& currentLedger = context.netOps_.getCurrentLedger (); auto const& currentLedger = context.netOps.getCurrentLedger ();
Json::Value jCurrent = RPC::accountFromString ( Json::Value jCurrent = RPC::accountFromString (
currentLedger, currentLedger,
raAccount, raAccount,
@@ -65,9 +65,9 @@ Json::Value doOwnerInfo (RPC::Context& context)
strIdent, strIdent,
iIndex, iIndex,
false, false,
context.netOps_); context.netOps);
ret["current"] = jCurrent.empty () ? context.netOps_.getOwnerInfo ( ret["current"] = jCurrent.empty () ? context.netOps.getOwnerInfo (
currentLedger, raAccount) : jCurrent; currentLedger, raAccount) : jCurrent;
return ret; return ret;

View File

@@ -22,46 +22,46 @@ namespace ripple {
Json::Value doPathFind (RPC::Context& context) Json::Value doPathFind (RPC::Context& context)
{ {
Ledger::pointer lpLedger = context.netOps_.getClosedLedger(); Ledger::pointer lpLedger = context.netOps.getClosedLedger();
if (!context.params_.isMember ("subcommand") || if (!context.params.isMember ("subcommand") ||
!context.params_["subcommand"].isString ()) !context.params["subcommand"].isString ())
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
if (!context.infoSub_) if (!context.infoSub)
return rpcError (rpcNO_EVENTS); return rpcError (rpcNO_EVENTS);
std::string sSubCommand = context.params_["subcommand"].asString (); std::string sSubCommand = context.params["subcommand"].asString ();
if (sSubCommand == "create") if (sSubCommand == "create")
{ {
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
context.infoSub_->clearPathRequest (); context.infoSub->clearPathRequest ();
return getApp().getPathRequests().makePathRequest ( return getApp().getPathRequests().makePathRequest (
context.infoSub_, lpLedger, context.params_); context.infoSub, lpLedger, context.params);
} }
if (sSubCommand == "close") if (sSubCommand == "close")
{ {
PathRequest::pointer request = context.infoSub_->getPathRequest (); PathRequest::pointer request = context.infoSub->getPathRequest ();
if (!request) if (!request)
return rpcError (rpcNO_PF_REQUEST); return rpcError (rpcNO_PF_REQUEST);
context.infoSub_->clearPathRequest (); context.infoSub->clearPathRequest ();
return request->doClose (context.params_); return request->doClose (context.params);
} }
if (sSubCommand == "status") if (sSubCommand == "status")
{ {
PathRequest::pointer request = context.infoSub_->getPathRequest (); PathRequest::pointer request = context.infoSub->getPathRequest ();
if (!request) if (!request)
return rpcError (rpcNO_PF_REQUEST); return rpcError (rpcNO_PF_REQUEST);
return request->doStatus (context.params_); return request->doStatus (context.params);
} }
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);

View File

@@ -23,11 +23,11 @@ namespace ripple {
Json::Value doPrint (RPC::Context& context) Json::Value doPrint (RPC::Context& context)
{ {
JsonPropertyStream stream; JsonPropertyStream stream;
if (context.params_.isObject() if (context.params.isObject()
&& context.params_["params"].isArray() && context.params["params"].isArray()
&& context.params_["params"][0u].isString ()) && context.params["params"][0u].isString ())
{ {
getApp().write (stream, context.params_["params"][0u].asString()); getApp().write (stream, context.params["params"][0u].asString());
} }
else else
{ {

View File

@@ -31,18 +31,18 @@ Json::Value doProofCreate (RPC::Context& context)
// XXX: Add ability to create proof with arbitrary time // XXX: Add ability to create proof with arbitrary time
Json::Value jvResult (Json::objectValue); Json::Value jvResult (Json::objectValue);
if (context.params_.isMember ("difficulty") || if (context.params.isMember ("difficulty") ||
context.params_.isMember ("secret")) context.params.isMember ("secret"))
{ {
// VFALCO TODO why aren't we using the app's factory? // VFALCO TODO why aren't we using the app's factory?
auto pgGen = make_ProofOfWorkFactory (); auto pgGen = make_ProofOfWorkFactory ();
if (context.params_.isMember ("difficulty")) if (context.params.isMember ("difficulty"))
{ {
if (!context.params_["difficulty"].isIntegral ()) if (!context.params["difficulty"].isIntegral ())
return RPC::invalid_field_error ("difficulty"); return RPC::invalid_field_error ("difficulty");
int const iDifficulty (context.params_["difficulty"].asInt ()); int const iDifficulty (context.params["difficulty"].asInt ());
if (iDifficulty < 0 || if (iDifficulty < 0 ||
iDifficulty > ProofOfWorkFactory::kMaxDifficulty) iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
@@ -53,9 +53,9 @@ Json::Value doProofCreate (RPC::Context& context)
pgGen->setDifficulty (iDifficulty); pgGen->setDifficulty (iDifficulty);
} }
if (context.params_.isMember ("secret")) if (context.params.isMember ("secret"))
{ {
uint256 uSecret (context.params_["secret"].asString ()); uint256 uSecret (context.params["secret"].asString ());
pgGen->setSecret (uSecret); pgGen->setSecret (uSecret);
} }

View File

@@ -27,10 +27,10 @@ Json::Value doProofSolve (RPC::Context& context)
{ {
Json::Value jvResult; Json::Value jvResult;
if (!context.params_.isMember ("token")) if (!context.params.isMember ("token"))
return RPC::missing_field_error ("token"); return RPC::missing_field_error ("token");
std::string strToken = context.params_["token"].asString (); std::string strToken = context.params["token"].asString ();
if (!ProofOfWork::validateToken (strToken)) if (!ProofOfWork::validateToken (strToken))
return RPC::invalid_field_error ("token"); return RPC::invalid_field_error ("token");

View File

@@ -33,29 +33,29 @@ Json::Value doProofVerify (RPC::Context& context)
Json::Value jvResult; Json::Value jvResult;
if (!context.params_.isMember ("token")) if (!context.params.isMember ("token"))
return RPC::missing_field_error ("token"); return RPC::missing_field_error ("token");
if (!context.params_.isMember ("solution")) if (!context.params.isMember ("solution"))
return RPC::missing_field_error ("solution"); return RPC::missing_field_error ("solution");
std::string strToken = context.params_["token"].asString (); std::string strToken = context.params["token"].asString ();
uint256 uSolution (context.params_["solution"].asString ()); uint256 uSolution (context.params["solution"].asString ());
PowResult prResult; PowResult prResult;
if (context.params_.isMember ("difficulty") || if (context.params.isMember ("difficulty") ||
context.params_.isMember ("secret")) context.params.isMember ("secret"))
{ {
// VFALCO TODO why aren't we using the app's factory? // VFALCO TODO why aren't we using the app's factory?
auto pgGen = make_ProofOfWorkFactory (); auto pgGen = make_ProofOfWorkFactory ();
if (context.params_.isMember ("difficulty")) if (context.params.isMember ("difficulty"))
{ {
if (!context.params_["difficulty"].isIntegral ()) if (!context.params["difficulty"].isIntegral ())
return RPC::invalid_field_error ("difficulty"); return RPC::invalid_field_error ("difficulty");
int iDifficulty = context.params_["difficulty"].asInt (); int iDifficulty = context.params["difficulty"].asInt ();
if (iDifficulty < 0 || if (iDifficulty < 0 ||
iDifficulty > ProofOfWorkFactory::kMaxDifficulty) iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
@@ -66,9 +66,9 @@ Json::Value doProofVerify (RPC::Context& context)
pgGen->setDifficulty (iDifficulty); pgGen->setDifficulty (iDifficulty);
} }
if (context.params_.isMember ("secret")) if (context.params.isMember ("secret"))
{ {
uint256 uSecret (context.params_["secret"].asString ()); uint256 uSecret (context.params["secret"].asString ());
pgGen->setSecret (uSecret); pgGen->setSecret (uSecret);
} }

View File

@@ -18,17 +18,18 @@
//============================================================================== //==============================================================================
#include <ripple/rpc/impl/LegacyPathFind.h> #include <ripple/rpc/impl/LegacyPathFind.h>
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
// This interface is deprecated. // This interface is deprecated.
Json::Value doRipplePathFind (RPC::Context& context) Json::Value doRipplePathFind (RPC::Context& context)
{ {
RPC::LegacyPathFind lpf (context.role_ == Role::ADMIN); RPC::LegacyPathFind lpf (context.role == Role::ADMIN);
if (!lpf.isOk ()) if (!lpf.isOk ())
return rpcError (rpcTOO_BUSY); return rpcError (rpcTOO_BUSY);
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
RippleAddress raSrc; RippleAddress raSrc;
RippleAddress raDst; RippleAddress raDst;
@@ -38,41 +39,41 @@ Json::Value doRipplePathFind (RPC::Context& context)
Json::Value jvResult; Json::Value jvResult;
if (getConfig().RUN_STANDALONE || if (getConfig().RUN_STANDALONE ||
context.params_.isMember(jss::ledger) || context.params.isMember(jss::ledger) ||
context.params_.isMember(jss::ledger_index) || context.params.isMember(jss::ledger_index) ||
context.params_.isMember(jss::ledger_hash)) context.params.isMember(jss::ledger_hash))
{ {
// The caller specified a ledger // The caller specified a ledger
jvResult = RPC::lookupLedger ( jvResult = RPC::lookupLedger (
context.params_, lpLedger, context.netOps_); context.params, lpLedger, context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
} }
if (!context.params_.isMember ("source_account")) if (!context.params.isMember ("source_account"))
{ {
jvResult = rpcError (rpcSRC_ACT_MISSING); jvResult = rpcError (rpcSRC_ACT_MISSING);
} }
else if (!context.params_["source_account"].isString () else if (!context.params["source_account"].isString ()
|| !raSrc.setAccountID ( || !raSrc.setAccountID (
context.params_["source_account"].asString ())) context.params["source_account"].asString ()))
{ {
jvResult = rpcError (rpcSRC_ACT_MALFORMED); jvResult = rpcError (rpcSRC_ACT_MALFORMED);
} }
else if (!context.params_.isMember ("destination_account")) else if (!context.params.isMember ("destination_account"))
{ {
jvResult = rpcError (rpcDST_ACT_MISSING); jvResult = rpcError (rpcDST_ACT_MISSING);
} }
else if (!context.params_["destination_account"].isString () else if (!context.params["destination_account"].isString ()
|| !raDst.setAccountID ( || !raDst.setAccountID (
context.params_["destination_account"].asString ())) context.params["destination_account"].asString ()))
{ {
jvResult = rpcError (rpcDST_ACT_MALFORMED); jvResult = rpcError (rpcDST_ACT_MALFORMED);
} }
else if ( else if (
// Parse saDstAmount. // Parse saDstAmount.
!context.params_.isMember ("destination_amount") !context.params.isMember ("destination_amount")
|| ! amountFromJsonNoThrow(saDstAmount, context.params_["destination_amount"]) || ! amountFromJsonNoThrow(saDstAmount, context.params["destination_amount"])
|| saDstAmount <= zero || saDstAmount <= zero
|| (!isXRP(saDstAmount.getCurrency ()) || (!isXRP(saDstAmount.getCurrency ())
&& (!saDstAmount.getIssuer () || && (!saDstAmount.getIssuer () ||
@@ -83,9 +84,9 @@ Json::Value doRipplePathFind (RPC::Context& context)
} }
else if ( else if (
// Checks on source_currencies. // Checks on source_currencies.
context.params_.isMember ("source_currencies") context.params.isMember ("source_currencies")
&& (!context.params_["source_currencies"].isArray () && (!context.params["source_currencies"].isArray ()
|| !context.params_["source_currencies"].size ()) || !context.params["source_currencies"].size ())
// Don't allow empty currencies. // Don't allow empty currencies.
) )
{ {
@@ -94,7 +95,7 @@ Json::Value doRipplePathFind (RPC::Context& context)
} }
else else
{ {
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
RippleLineCache::pointer cache; RippleLineCache::pointer cache;
if (lpLedger) if (lpLedger)
@@ -107,15 +108,15 @@ Json::Value doRipplePathFind (RPC::Context& context)
{ {
// The closed ledger is recent and any nodes made resident // The closed ledger is recent and any nodes made resident
// have the best chance to persist // have the best chance to persist
lpLedger = context.netOps_.getClosedLedger(); lpLedger = context.netOps.getClosedLedger();
cache = getApp().getPathRequests().getLineCache(lpLedger, false); cache = getApp().getPathRequests().getLineCache(lpLedger, false);
} }
Json::Value jvSrcCurrencies; Json::Value jvSrcCurrencies;
if (context.params_.isMember ("source_currencies")) if (context.params.isMember ("source_currencies"))
{ {
jvSrcCurrencies = context.params_["source_currencies"]; jvSrcCurrencies = context.params["source_currencies"];
} }
else else
{ {
@@ -188,17 +189,17 @@ Json::Value doRipplePathFind (RPC::Context& context)
{ {
++level; ++level;
} }
if (context.params_.isMember("depth") if (context.params.isMember("depth")
&& context.params_["depth"].isIntegral()) && context.params["depth"].isIntegral())
{ {
int rLev = context.params_["search_depth"].asInt (); int rLev = context.params["search_depth"].asInt ();
if ((rLev < level) || (context.role_ == Role::ADMIN)) if ((rLev < level) || (context.role == Role::ADMIN))
level = rLev; level = rLev;
} }
if (context.params_.isMember("paths")) if (context.params.isMember("paths"))
{ {
STParsedJSONObject paths ("paths", context.params_["paths"]); STParsedJSONObject paths ("paths", context.params["paths"]);
if (paths.object.get() == nullptr) if (paths.object.get() == nullptr)
return paths.error; return paths.error;
else else

View File

@@ -22,11 +22,11 @@ namespace ripple {
Json::Value doSMS (RPC::Context& context) Json::Value doSMS (RPC::Context& context)
{ {
if (!context.params_.isMember ("text")) if (!context.params.isMember ("text"))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
HTTPClient::sendSMS ( HTTPClient::sendSMS (
getApp().getIOService (), context.params_["text"].asString ()); getApp().getIOService (), context.params["text"].asString ());
return "sms dispatched"; return "sms dispatched";
} }

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -25,8 +26,8 @@ Json::Value doServerInfo (RPC::Context& context)
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
Json::Value ret (Json::objectValue); Json::Value ret (Json::objectValue);
ret["info"] = context.netOps_.getServerInfo ( ret["info"] = context.netOps.getServerInfo (
true, context.role_ == Role::ADMIN); true, context.role == Role::ADMIN);
return ret; return ret;
} }

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -25,8 +26,8 @@ Json::Value doServerState (RPC::Context& context)
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
Json::Value ret (Json::objectValue); Json::Value ret (Json::objectValue);
ret["state"] = context.netOps_.getServerInfo ( ret["state"] = context.netOps.getServerInfo (
false, context.role_ == Role::ADMIN); false, context.role == Role::ADMIN);
return ret; return ret;
} }

View File

@@ -27,11 +27,11 @@ namespace ripple {
// } // }
Json::Value doSign (RPC::Context& context) Json::Value doSign (RPC::Context& context)
{ {
context.loadType_ = Resource::feeHighBurdenRPC; context.loadType = Resource::feeHighBurdenRPC;
bool bFailHard = context.params_.isMember ("fail_hard") bool bFailHard = context.params.isMember ("fail_hard")
&& context.params_["fail_hard"].asBool (); && context.params["fail_hard"].asBool ();
return RPC::transactionSign ( return RPC::transactionSign (
context.params_, false, bFailHard, context.netOps_, context.role_); context.params, false, bFailHard, context.netOps, context.role);
} }
} // ripple } // ripple

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include <ripple/basics/StringUtilities.h> #include <ripple/basics/StringUtilities.h>
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -27,19 +28,19 @@ namespace ripple {
// } // }
Json::Value doSubmit (RPC::Context& context) Json::Value doSubmit (RPC::Context& context)
{ {
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
if (!context.params_.isMember ("tx_blob")) if (!context.params.isMember ("tx_blob"))
{ {
bool bFailHard = context.params_.isMember ("fail_hard") bool bFailHard = context.params.isMember ("fail_hard")
&& context.params_["fail_hard"].asBool (); && context.params["fail_hard"].asBool ();
return RPC::transactionSign ( return RPC::transactionSign (
context.params_, true, bFailHard, context.netOps_, context.role_); context.params, true, bFailHard, context.netOps, context.role);
} }
Json::Value jvResult; Json::Value jvResult;
std::pair<Blob, bool> ret(strUnHex (context.params_["tx_blob"].asString ())); std::pair<Blob, bool> ret(strUnHex (context.params["tx_blob"].asString ()));
if (!ret.second || !ret.first.size ()) if (!ret.second || !ret.first.size ())
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
@@ -85,10 +86,10 @@ Json::Value doSubmit (RPC::Context& context)
try try
{ {
(void) context.netOps_.processTransaction ( (void) context.netOps.processTransaction (
tpTrans, context.role_ == Role::ADMIN, true, tpTrans, context.role == Role::ADMIN, true,
context.params_.isMember ("fail_hard") context.params.isMember ("fail_hard")
&& context.params_["fail_hard"].asBool ()); && context.params["fail_hard"].asBool ());
} }
catch (std::exception& e) catch (std::exception& e)
{ {

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include <ripple/rpc/impl/ParseAccountIds.h> #include <ripple/rpc/impl/ParseAccountIds.h>
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -30,12 +31,12 @@ Json::Value doSubscribe (RPC::Context& context)
InfoSub::pointer ispSub; InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue); Json::Value jvResult (Json::objectValue);
std::uint32_t uLedgerIndex = context.params_.isMember (jss::ledger_index) std::uint32_t uLedgerIndex = context.params.isMember (jss::ledger_index)
&& context.params_[jss::ledger_index].isNumeric () && context.params[jss::ledger_index].isNumeric ()
? context.params_[jss::ledger_index].asUInt () ? context.params[jss::ledger_index].asUInt ()
: 0; : 0;
if (!context.infoSub_ && !context.params_.isMember ("url")) if (!context.infoSub && !context.params.isMember ("url"))
{ {
// Must be a JSON-RPC call. // Must be a JSON-RPC call.
WriteLog (lsINFO, RPCHandler) WriteLog (lsINFO, RPCHandler)
@@ -44,26 +45,26 @@ Json::Value doSubscribe (RPC::Context& context)
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
if (context.params_.isMember ("url")) if (context.params.isMember ("url"))
{ {
if (context.role_ != Role::ADMIN) if (context.role != Role::ADMIN)
return rpcError (rpcNO_PERMISSION); return rpcError (rpcNO_PERMISSION);
std::string strUrl = context.params_["url"].asString (); std::string strUrl = context.params["url"].asString ();
std::string strUsername = context.params_.isMember ("url_username") ? std::string strUsername = context.params.isMember ("url_username") ?
context.params_["url_username"].asString () : ""; context.params["url_username"].asString () : "";
std::string strPassword = context.params_.isMember ("url_password") ? std::string strPassword = context.params.isMember ("url_password") ?
context.params_["url_password"].asString () : ""; context.params["url_password"].asString () : "";
// DEPRECATED // DEPRECATED
if (context.params_.isMember ("username")) if (context.params.isMember ("username"))
strUsername = context.params_["username"].asString (); strUsername = context.params["username"].asString ();
// DEPRECATED // DEPRECATED
if (context.params_.isMember ("password")) if (context.params.isMember ("password"))
strPassword = context.params_["password"].asString (); strPassword = context.params["password"].asString ();
ispSub = context.netOps_.findRpcSub (strUrl); ispSub = context.netOps.findRpcSub (strUrl);
if (!ispSub) if (!ispSub)
{ {
@@ -73,7 +74,7 @@ Json::Value doSubscribe (RPC::Context& context)
RPCSub::pointer rspSub = RPCSub::New (getApp ().getOPs (), RPCSub::pointer rspSub = RPCSub::New (getApp ().getOPs (),
getApp ().getIOService (), getApp ().getJobQueue (), getApp ().getIOService (), getApp ().getJobQueue (),
strUrl, strUsername, strPassword); strUrl, strUsername, strPassword);
ispSub = context.netOps_.addRpcSub ( ispSub = context.netOps.addRpcSub (
strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub)); strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub));
} }
else else
@@ -81,22 +82,22 @@ Json::Value doSubscribe (RPC::Context& context)
WriteLog (lsTRACE, RPCHandler) WriteLog (lsTRACE, RPCHandler)
<< "doSubscribe: reusing: " << strUrl; << "doSubscribe: reusing: " << strUrl;
if (context.params_.isMember ("username")) if (context.params.isMember ("username"))
dynamic_cast<RPCSub*> (&*ispSub)->setUsername (strUsername); dynamic_cast<RPCSub*> (&*ispSub)->setUsername (strUsername);
if (context.params_.isMember ("password")) if (context.params.isMember ("password"))
dynamic_cast<RPCSub*> (&*ispSub)->setPassword (strPassword); dynamic_cast<RPCSub*> (&*ispSub)->setPassword (strPassword);
} }
} }
else else
{ {
ispSub = context.infoSub_; ispSub = context.infoSub;
} }
if (!context.params_.isMember ("streams")) if (!context.params.isMember ("streams"))
{ {
} }
else if (!context.params_["streams"].isArray ()) else if (!context.params["streams"].isArray ())
{ {
WriteLog (lsINFO, RPCHandler) WriteLog (lsINFO, RPCHandler)
<< "doSubscribe: streams requires an array."; << "doSubscribe: streams requires an array.";
@@ -105,7 +106,7 @@ Json::Value doSubscribe (RPC::Context& context)
} }
else else
{ {
for (auto& it: context.params_["streams"]) for (auto& it: context.params["streams"])
{ {
if (it.isString ()) if (it.isString ())
{ {
@@ -113,21 +114,21 @@ Json::Value doSubscribe (RPC::Context& context)
if (streamName == "server") if (streamName == "server")
{ {
context.netOps_.subServer (ispSub, jvResult, context.netOps.subServer (ispSub, jvResult,
context.role_ == Role::ADMIN); context.role == Role::ADMIN);
} }
else if (streamName == "ledger") else if (streamName == "ledger")
{ {
context.netOps_.subLedger (ispSub, jvResult); context.netOps.subLedger (ispSub, jvResult);
} }
else if (streamName == "transactions") else if (streamName == "transactions")
{ {
context.netOps_.subTransactions (ispSub); context.netOps.subTransactions (ispSub);
} }
else if (streamName == "transactions_proposed" else if (streamName == "transactions_proposed"
|| streamName == "rt_transactions") // DEPRECATED || streamName == "rt_transactions") // DEPRECATED
{ {
context.netOps_.subRTTransactions (ispSub); context.netOps.subRTTransactions (ispSub);
} }
else else
{ {
@@ -142,36 +143,36 @@ Json::Value doSubscribe (RPC::Context& context)
} }
std::string strAccountsProposed = std::string strAccountsProposed =
context.params_.isMember ("accounts_proposed") context.params.isMember ("accounts_proposed")
? "accounts_proposed" : "rt_accounts"; // DEPRECATED ? "accounts_proposed" : "rt_accounts"; // DEPRECATED
if (!context.params_.isMember (strAccountsProposed)) if (!context.params.isMember (strAccountsProposed))
{ {
} }
else if (!context.params_[strAccountsProposed].isArray ()) else if (!context.params[strAccountsProposed].isArray ())
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
else else
{ {
auto ids = RPC::parseAccountIds (context.params_[strAccountsProposed]); auto ids = RPC::parseAccountIds (context.params[strAccountsProposed]);
if (ids.empty ()) if (ids.empty ())
jvResult[jss::error] = "malformedAccount"; jvResult[jss::error] = "malformedAccount";
else else
context.netOps_.subAccount (ispSub, ids, uLedgerIndex, true); context.netOps.subAccount (ispSub, ids, uLedgerIndex, true);
} }
if (!context.params_.isMember ("accounts")) if (!context.params.isMember ("accounts"))
{ {
} }
else if (!context.params_["accounts"].isArray ()) else if (!context.params["accounts"].isArray ())
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
else else
{ {
auto ids = RPC::parseAccountIds (context.params_["accounts"]); auto ids = RPC::parseAccountIds (context.params["accounts"]);
if (ids.empty ()) if (ids.empty ())
{ {
@@ -179,23 +180,23 @@ Json::Value doSubscribe (RPC::Context& context)
} }
else else
{ {
context.netOps_.subAccount (ispSub, ids, uLedgerIndex, false); context.netOps.subAccount (ispSub, ids, uLedgerIndex, false);
WriteLog (lsDEBUG, RPCHandler) WriteLog (lsDEBUG, RPCHandler)
<< "doSubscribe: accounts: " << ids.size (); << "doSubscribe: accounts: " << ids.size ();
} }
} }
bool bHaveMasterLock = true; bool bHaveMasterLock = true;
if (!context.params_.isMember ("books")) if (!context.params.isMember ("books"))
{ {
} }
else if (!context.params_["books"].isArray ()) else if (!context.params["books"].isArray ())
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
else else
{ {
for (auto& j: context.params_["books"]) for (auto& j: context.params["books"])
{ {
if (!j.isObject () if (!j.isObject ()
|| !j.isMember (jss::taker_pays) || !j.isMember (jss::taker_pays)
@@ -284,10 +285,10 @@ Json::Value doSubscribe (RPC::Context& context)
return rpcError (rpcBAD_MARKET); return rpcError (rpcBAD_MARKET);
} }
context.netOps_.subBook (ispSub, book); context.netOps.subBook (ispSub, book);
if (bBoth) if (bBoth)
context.netOps_.subBook (ispSub, book); context.netOps.subBook (ispSub, book);
if (bSnapshot) if (bSnapshot)
{ {
@@ -297,7 +298,7 @@ Json::Value doSubscribe (RPC::Context& context)
bHaveMasterLock = false; bHaveMasterLock = false;
} }
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
auto lpLedger = getApp().getLedgerMaster (). auto lpLedger = getApp().getLedgerMaster ().
getPublishedLedger (); getPublishedLedger ();
if (lpLedger) if (lpLedger)
@@ -309,14 +310,14 @@ Json::Value doSubscribe (RPC::Context& context)
Json::Value jvBids (Json::objectValue); Json::Value jvBids (Json::objectValue);
Json::Value jvAsks (Json::objectValue); Json::Value jvAsks (Json::objectValue);
context.netOps_.getBookPage ( context.netOps.getBookPage (
lpLedger, book, raTakerID.getAccountID (), false, 0, lpLedger, book, raTakerID.getAccountID (), false, 0,
jvMarker, jvBids); jvMarker, jvBids);
if (jvBids.isMember (jss::offers)) if (jvBids.isMember (jss::offers))
jvResult[jss::bids] = jvBids[jss::offers]; jvResult[jss::bids] = jvBids[jss::offers];
context.netOps_.getBookPage ( context.netOps.getBookPage (
lpLedger, book, raTakerID.getAccountID (), lpLedger, book, raTakerID.getAccountID (),
false, 0, jvMarker, jvAsks); false, 0, jvMarker, jvAsks);
@@ -325,7 +326,7 @@ Json::Value doSubscribe (RPC::Context& context)
} }
else else
{ {
context.netOps_.getBookPage ( context.netOps.getBookPage (
lpLedger, book, raTakerID.getAccountID (), false, 0, lpLedger, book, raTakerID.getAccountID (), false, 0,
jvMarker, jvResult); jvMarker, jvResult);
} }

View File

@@ -31,19 +31,19 @@ Json::Value doTransactionEntry (RPC::Context& context)
{ {
Ledger::pointer lpLedger; Ledger::pointer lpLedger;
Json::Value jvResult = RPC::lookupLedger ( Json::Value jvResult = RPC::lookupLedger (
context.params_, context.params,
lpLedger, lpLedger,
context.netOps_); context.netOps);
if (!lpLedger) if (!lpLedger)
return jvResult; return jvResult;
if (!context.params_.isMember ("tx_hash")) if (!context.params.isMember ("tx_hash"))
{ {
jvResult["error"] = "fieldNotFoundTransaction"; jvResult["error"] = "fieldNotFoundTransaction";
} }
else if (!context.params_.isMember ("ledger_hash") else if (!context.params.isMember ("ledger_hash")
&& !context.params_.isMember ("ledger_index")) && !context.params.isMember ("ledger_index"))
{ {
// We don't work on ledger current. // We don't work on ledger current.
@@ -55,7 +55,7 @@ Json::Value doTransactionEntry (RPC::Context& context)
uint256 uTransID; uint256 uTransID;
// XXX Relying on trusted WSS client. Would be better to have a strict // XXX Relying on trusted WSS client. Would be better to have a strict
// routine, returning success or failure. // routine, returning success or failure.
uTransID.SetHex (context.params_["tx_hash"].asString ()); uTransID.SetHex (context.params["tx_hash"].asString ());
if (!lpLedger) if (!lpLedger)
{ {

View File

@@ -25,13 +25,13 @@ namespace ripple {
// } // }
Json::Value doTx (RPC::Context& context) Json::Value doTx (RPC::Context& context)
{ {
if (!context.params_.isMember (jss::transaction)) if (!context.params.isMember (jss::transaction))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
bool binary = context.params_.isMember (jss::binary) bool binary = context.params.isMember (jss::binary)
&& context.params_[jss::binary].asBool (); && context.params[jss::binary].asBool ();
std::string strTransaction = context.params_[jss::transaction].asString (); std::string strTransaction = context.params[jss::transaction].asString ();
if (Transaction::isHexTxID (strTransaction)) if (Transaction::isHexTxID (strTransaction))
{ {
@@ -53,7 +53,7 @@ Json::Value doTx (RPC::Context& context)
if (txn->getLedger () != 0) if (txn->getLedger () != 0)
{ {
if (auto lgr = context.netOps_.getLedgerBySeq (txn->getLedger ())) if (auto lgr = context.netOps.getLedgerBySeq (txn->getLedger ()))
{ {
bool okay = false; bool okay = false;
if (binary) if (binary)
@@ -77,7 +77,7 @@ Json::Value doTx (RPC::Context& context)
} }
if (okay) if (okay)
ret[jss::validated] = context.netOps_.isValidated (lgr); ret[jss::validated] = context.netOps.isValidated (lgr);
} }
} }

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -25,14 +26,14 @@ namespace ripple {
// } // }
Json::Value doTxHistory (RPC::Context& context) Json::Value doTxHistory (RPC::Context& context)
{ {
context.loadType_ = Resource::feeMediumBurdenRPC; context.loadType = Resource::feeMediumBurdenRPC;
if (!context.params_.isMember ("start")) if (!context.params.isMember ("start"))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
unsigned int startIndex = context.params_["start"].asUInt (); unsigned int startIndex = context.params["start"].asUInt ();
if ((startIndex > 10000) && (context.role_ != Role::ADMIN)) if ((startIndex > 10000) && (context.role != Role::ADMIN))
return rpcError (rpcNO_PERMISSION); return rpcError (rpcNO_PERMISSION);
Json::Value obj; Json::Value obj;

View File

@@ -28,10 +28,10 @@ Json::Value doUnlAdd (RPC::Context& context)
{ {
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
std::string strNode = context.params_.isMember ("node") std::string strNode = context.params.isMember ("node")
? context.params_["node"].asString () : ""; ? context.params["node"].asString () : "";
std::string strComment = context.params_.isMember ("comment") std::string strComment = context.params.isMember ("comment")
? context.params_["comment"].asString () : ""; ? context.params["comment"].asString () : "";
RippleAddress raNodePublic; RippleAddress raNodePublic;

View File

@@ -27,10 +27,10 @@ Json::Value doUnlDelete (RPC::Context& context)
{ {
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
if (!context.params_.isMember ("node")) if (!context.params.isMember ("node"))
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
auto strNode = context.params_["node"].asString (); auto strNode = context.params["node"].asString ();
RippleAddress raNodePublic; RippleAddress raNodePublic;
if (raNodePublic.setNodePublic (strNode)) if (raNodePublic.setNodePublic (strNode))

View File

@@ -17,6 +17,7 @@
*/ */
//============================================================================== //==============================================================================
#include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -29,48 +30,48 @@ Json::Value doUnsubscribe (RPC::Context& context)
InfoSub::pointer ispSub; InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue); Json::Value jvResult (Json::objectValue);
if (!context.infoSub_ && !context.params_.isMember ("url")) if (!context.infoSub && !context.params.isMember ("url"))
{ {
// Must be a JSON-RPC call. // Must be a JSON-RPC call.
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
if (context.params_.isMember ("url")) if (context.params.isMember ("url"))
{ {
if (context.role_ != Role::ADMIN) if (context.role != Role::ADMIN)
return rpcError (rpcNO_PERMISSION); return rpcError (rpcNO_PERMISSION);
std::string strUrl = context.params_["url"].asString (); std::string strUrl = context.params["url"].asString ();
ispSub = context.netOps_.findRpcSub (strUrl); ispSub = context.netOps.findRpcSub (strUrl);
if (!ispSub) if (!ispSub)
return jvResult; return jvResult;
} }
else else
{ {
ispSub = context.infoSub_; ispSub = context.infoSub;
} }
if (context.params_.isMember ("streams")) if (context.params.isMember ("streams"))
{ {
for (auto& it: context.params_["streams"]) for (auto& it: context.params["streams"])
{ {
if (it.isString ()) if (it.isString ())
{ {
std::string streamName = it.asString (); std::string streamName = it.asString ();
if (streamName == "server") if (streamName == "server")
context.netOps_.unsubServer (ispSub->getSeq ()); context.netOps.unsubServer (ispSub->getSeq ());
else if (streamName == "ledger") else if (streamName == "ledger")
context.netOps_.unsubLedger (ispSub->getSeq ()); context.netOps.unsubLedger (ispSub->getSeq ());
else if (streamName == "transactions") else if (streamName == "transactions")
context.netOps_.unsubTransactions (ispSub->getSeq ()); context.netOps.unsubTransactions (ispSub->getSeq ());
else if (streamName == "transactions_proposed" else if (streamName == "transactions_proposed"
|| streamName == "rt_transactions") // DEPRECATED || streamName == "rt_transactions") // DEPRECATED
context.netOps_.unsubRTTransactions (ispSub->getSeq ()); context.netOps.unsubRTTransactions (ispSub->getSeq ());
else else
jvResult["error"] = "Unknown stream: " + streamName; jvResult["error"] = "Unknown stream: " + streamName;
@@ -82,40 +83,40 @@ Json::Value doUnsubscribe (RPC::Context& context)
} }
} }
if (context.params_.isMember ("accounts_proposed") if (context.params.isMember ("accounts_proposed")
|| context.params_.isMember ("rt_accounts")) || context.params.isMember ("rt_accounts"))
{ {
auto accounts = RPC::parseAccountIds ( auto accounts = RPC::parseAccountIds (
context.params_.isMember ("accounts_proposed") context.params.isMember ("accounts_proposed")
? context.params_["accounts_proposed"] ? context.params["accounts_proposed"]
: context.params_["rt_accounts"]); // DEPRECATED : context.params["rt_accounts"]); // DEPRECATED
if (accounts.empty ()) if (accounts.empty ())
jvResult["error"] = "malformedAccount"; jvResult["error"] = "malformedAccount";
else else
context.netOps_.unsubAccount (ispSub->getSeq (), accounts, true); context.netOps.unsubAccount (ispSub->getSeq (), accounts, true);
} }
if (context.params_.isMember ("accounts")) if (context.params.isMember ("accounts"))
{ {
auto accounts = RPC::parseAccountIds (context.params_["accounts"]); auto accounts = RPC::parseAccountIds (context.params["accounts"]);
if (accounts.empty ()) if (accounts.empty ())
jvResult["error"] = "malformedAccount"; jvResult["error"] = "malformedAccount";
else else
context.netOps_.unsubAccount (ispSub->getSeq (), accounts, false); context.netOps.unsubAccount (ispSub->getSeq (), accounts, false);
} }
if (!context.params_.isMember ("books")) if (!context.params.isMember ("books"))
{ {
} }
else if (!context.params_["books"].isArray ()) else if (!context.params["books"].isArray ())
{ {
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);
} }
else else
{ {
for (auto& jv: context.params_["books"]) for (auto& jv: context.params["books"])
{ {
if (!jv.isObject () if (!jv.isObject ()
|| !jv.isMember ("taker_pays") || !jv.isMember ("taker_pays")
@@ -185,10 +186,10 @@ Json::Value doUnsubscribe (RPC::Context& context)
return rpcError (rpcBAD_MARKET); return rpcError (rpcBAD_MARKET);
} }
context.netOps_.unsubBook (ispSub->getSeq (), book); context.netOps.unsubBook (ispSub->getSeq (), book);
if (bBoth) if (bBoth)
context.netOps_.unsubBook (ispSub->getSeq (), book); context.netOps.unsubBook (ispSub->getSeq (), book);
} }
} }

View File

@@ -31,13 +31,13 @@ Json::Value doValidationCreate (RPC::Context& context)
RippleAddress raSeed; RippleAddress raSeed;
Json::Value obj (Json::objectValue); Json::Value obj (Json::objectValue);
if (!context.params_.isMember ("secret")) if (!context.params.isMember ("secret"))
{ {
WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed."; WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed.";
raSeed.setSeedRandom (); // Get a random seed. raSeed.setSeedRandom (); // Get a random seed.
} }
else if (!raSeed.setSeedGeneric (context.params_["secret"].asString ())) else if (!raSeed.setSeedGeneric (context.params["secret"].asString ()))
{ {
return rpcError (rpcBAD_SEED); return rpcError (rpcBAD_SEED);
} }

View File

@@ -28,7 +28,7 @@ Json::Value doValidationSeed (RPC::Context& context)
auto lock = getApp().masterLock(); auto lock = getApp().masterLock();
Json::Value obj (Json::objectValue); Json::Value obj (Json::objectValue);
if (!context.params_.isMember ("secret")) if (!context.params.isMember ("secret"))
{ {
std::cerr << "Unset validation seed." << std::endl; std::cerr << "Unset validation seed." << std::endl;
@@ -37,7 +37,7 @@ Json::Value doValidationSeed (RPC::Context& context)
getConfig ().VALIDATION_PRIV.clear (); getConfig ().VALIDATION_PRIV.clear ();
} }
else if (!getConfig ().VALIDATION_SEED.setSeedGeneric ( else if (!getConfig ().VALIDATION_SEED.setSeedGeneric (
context.params_["secret"].asString ())) context.params["secret"].asString ()))
{ {
getConfig ().VALIDATION_PUB.clear (); getConfig ().VALIDATION_PUB.clear ();
getConfig ().VALIDATION_PRIV.clear (); getConfig ().VALIDATION_PRIV.clear ();

View File

@@ -31,15 +31,15 @@ Json::Value doWalletAccounts (RPC::Context& context)
{ {
Ledger::pointer ledger; Ledger::pointer ledger;
Json::Value jvResult Json::Value jvResult
= RPC::lookupLedger (context.params_, ledger, context.netOps_); = RPC::lookupLedger (context.params, ledger, context.netOps);
if (!ledger) if (!ledger)
return jvResult; return jvResult;
RippleAddress naSeed; RippleAddress naSeed;
if (!context.params_.isMember ("seed") if (!context.params.isMember ("seed")
|| !naSeed.setSeedGeneric (context.params_["seed"].asString ())) || !naSeed.setSeedGeneric (context.params["seed"].asString ()))
{ {
return rpcError (rpcBAD_SEED); return rpcError (rpcBAD_SEED);
} }
@@ -49,19 +49,19 @@ Json::Value doWalletAccounts (RPC::Context& context)
= RippleAddress::createGeneratorPublic (naSeed); = RippleAddress::createGeneratorPublic (naSeed);
Json::Value jsonAccounts Json::Value jsonAccounts
= RPC::accounts (ledger, naMasterGenerator, context.netOps_); = RPC::accounts (ledger, naMasterGenerator, context.netOps);
if (jsonAccounts.empty ()) if (jsonAccounts.empty ())
{ {
// No account via seed as master, try seed a regular. // No account via seed as master, try seed a regular.
Json::Value ret = RPC::getMasterGenerator ( Json::Value ret = RPC::getMasterGenerator (
ledger, naSeed, naMasterGenerator, context.netOps_); ledger, naSeed, naMasterGenerator, context.netOps);
if (!ret.empty ()) if (!ret.empty ())
return ret; return ret;
ret["accounts"] ret["accounts"]
= RPC::accounts (ledger, naMasterGenerator, context.netOps_); = RPC::accounts (ledger, naMasterGenerator, context.netOps);
return ret; return ret;
} }
else else

View File

@@ -28,10 +28,10 @@ Json::Value doWalletPropose (RPC::Context& context)
RippleAddress naSeed; RippleAddress naSeed;
RippleAddress naAccount; RippleAddress naAccount;
if (!context.params_.isMember ("passphrase")) if (!context.params.isMember ("passphrase"))
naSeed.setSeedRandom (); naSeed.setSeedRandom ();
else if (!naSeed.setSeedGeneric (context.params_["passphrase"].asString ())) else if (!naSeed.setSeedGeneric (context.params["passphrase"].asString ()))
return rpcError(rpcBAD_SEED); return rpcError(rpcBAD_SEED);
RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed); RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed);

View File

@@ -25,9 +25,9 @@ namespace ripple {
Json::Value doWalletSeed (RPC::Context& context) Json::Value doWalletSeed (RPC::Context& context)
{ {
RippleAddress seed; RippleAddress seed;
bool bSecret = context.params_.isMember ("secret"); bool bSecret = context.params.isMember ("secret");
if (bSecret && !seed.setSeedGeneric (context.params_["secret"].asString ())) if (bSecret && !seed.setSeedGeneric (context.params["secret"].asString ()))
{ {
return rpcError (rpcBAD_SEED); return rpcError (rpcBAD_SEED);
} }

View File

@@ -29,12 +29,11 @@ namespace RPC {
/** The context of information needed to call an RPC. */ /** The context of information needed to call an RPC. */
struct Context struct Context
{ {
// VFALCO NOTE Public members should not have underscores appended Json::Value params;
Json::Value params_; Resource::Charge& loadType;
Resource::Charge& loadType_; NetworkOPs& netOps;
NetworkOPs& netOps_; InfoSub::pointer infoSub;
InfoSub::pointer infoSub_; Role role;
Role role_;
}; };
} // RPC } // RPC