New ResourceManager for managing server load.

* Track abusive endpoints
* Gossip across cluster.
* Use resource manager's gossip support to share load reporting across a cluster
* Swtich from legacy fees to new Resource::Charge fees.
* Connect RPC to the new resource manager.
* Set load levels where needed in RPC/websocket commands.
* Disconnect abusive peer endpoints.
* Don't start conversations with abusive peer endpoints.
* Move Resource::Consumer to InfoSub and remove LoadSource
* Remove port from inbound Consumer keys
* Add details in getJson
* Fix doAccountCurrencies for the new resource manager.
This commit is contained in:
David Schwartz
2013-10-29 17:35:47 -07:00
committed by Vinnie Falco
parent a05f33f6a7
commit 58f07a573f
48 changed files with 665 additions and 759 deletions

View File

@@ -575,7 +575,7 @@ Json::Value RPCHandler::accountFromString (Ledger::ref lrLedger, RippleAddress&
return Json::Value (Json::objectValue);
}
Json::Value RPCHandler::doAccountCurrencies (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountCurrencies (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -641,7 +641,7 @@ Json::Value RPCHandler::doAccountCurrencies (Json::Value params, LoadType* loadT
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -682,13 +682,13 @@ Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, A
return jvResult;
}
Json::Value RPCHandler::doBlackList (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doBlackList (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock();
if (params.isMember("threshold"))
return getApp().getLoadManager().getBlackList(params["threshold"].asInt());
return getApp().getResourceManager().getJson(params["threshold"].asInt());
else
return getApp().getLoadManager().getBlackList();
return getApp().getResourceManager().getJson();
}
// {
@@ -696,7 +696,7 @@ Json::Value RPCHandler::doBlackList (Json::Value params, LoadType* loadType, App
// port: <number>
// }
// XXX Might allow domain for manual connections.
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doConnect (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (getConfig ().RUN_STANDALONE)
return "cannot connect in standalone mode";
@@ -717,7 +717,7 @@ Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Appli
// {
// key: <string>
// }
Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doDataDelete (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key"))
return rpcError (rpcINVALID_PARAMS);
@@ -743,7 +743,7 @@ Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Ap
// {
// key: <string>
// }
Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doDataFetch (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key"))
return rpcError (rpcINVALID_PARAMS);
@@ -767,7 +767,7 @@ Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, App
// key: <string>
// value: <string>
// }
Json::Value RPCHandler::doDataStore (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doDataStore (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key")
|| !params.isMember ("value"))
@@ -828,7 +828,7 @@ Json::Value RPCHandler::doNicknameInfo (Json::Value params)
// 'account_index' : <index> // optional
// }
// XXX This would be better if it took the ledger.
Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doOwnerInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("account") && !params.isMember ("ident"))
return rpcError (rpcINVALID_PARAMS);
@@ -853,7 +853,7 @@ Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, App
return ret;
}
Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doPeers (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult (Json::objectValue);
@@ -864,12 +864,12 @@ Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, Application::S
return jvResult;
}
Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doPing (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
return Json::Value (Json::objectValue);
}
Json::Value RPCHandler::doPrint (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doPrint (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
@@ -887,7 +887,7 @@ Json::Value RPCHandler::doPrint (Json::Value params, LoadType* loadType, Applica
// issuer is the offering account
// --> submit: 'submit|true|false': defaults to false
// Prior to running allow each to have a credit line of what they will be getting from the other account.
Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doProfile (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
/* need to fix now that sharedOfferCreate is gone
int iArgs = params.size();
@@ -979,7 +979,7 @@ Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Appli
// difficulty: <number> // optional
// secret: <secret> // optional
// }
Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doProofCreate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
// XXX: Add ability to create proof with arbitrary time
@@ -1024,7 +1024,7 @@ Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, A
// {
// token: <token>
// }
Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doProofSolve (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
@@ -1054,7 +1054,7 @@ Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Ap
// difficulty: <number> // optional
// secret: <secret> // optional
// }
Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doProofVerify (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
// XXX Add ability to check proof against arbitrary time
@@ -1124,7 +1124,7 @@ Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, A
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -1215,6 +1215,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType,
}
}
loadType = Resource::feeMediumBurdenRPC;
}
else
{
@@ -1242,7 +1243,7 @@ static void offerAdder (Json::Value& jvLines, SLE::ref offer)
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -1287,6 +1288,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
if (!bUnlocked)
masterLockHolder.unlock ();
loadType = Resource::feeMediumBurdenRPC;
return jvResult;
}
@@ -1301,7 +1303,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
// "limit" : integer, // Optional.
// "proof" : boolean // Defaults to false.
// }
Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (getApp().getJobQueue ().getJobCountGE (jtCLIENT) > 200)
{
@@ -1394,6 +1396,7 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Ap
const Json::Value jvMarker = params.isMember ("marker") ? params["marker"] : Json::Value (Json::nullValue);
mNetOps->getBookPage (lpLedger, uTakerPaysCurrencyID, uTakerPaysIssuerID, uTakerGetsCurrencyID, uTakerGetsIssuerID, raTakerID.getAccountID (), bProof, iLimit, jvMarker, jvResult);
loadType = Resource::feeMediumBurdenRPC;
return jvResult;
}
@@ -1402,7 +1405,7 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Ap
// {
// random: <uint256>
// }
Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doRandom (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
uint256 uRandom;
@@ -1423,7 +1426,7 @@ Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Applic
}
}
Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doPathFind (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger = mNetOps->getClosedLedger();
masterLockHolder.unlock();
@@ -1438,6 +1441,7 @@ Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Appl
if (sSubCommand == "create")
{
loadType = Resource::feeHighBurdenRPC;
mInfoSub->clearPathRequest ();
PathRequest::pointer request = boost::make_shared<PathRequest> (mInfoSub);
Json::Value result = request->doCreate (lpLedger, params);
@@ -1481,7 +1485,7 @@ Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Appl
// - Allows clients to verify path exists.
// - Return canonicalized path.
// - From a trusted server, allows clients to use path without manipulation.
Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doRipplePathFind (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
@@ -1490,6 +1494,7 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
WriteLog (lsDEBUG, RPCHandler) << "Too busy for RPF: " << jc;
return rpcError (rpcTOO_BUSY);
}
loadType = Resource::feeHighBurdenRPC;
RippleAddress raSrc;
RippleAddress raDst;
@@ -1562,7 +1567,7 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
}
}
*loadType = LT_RPCBurden;
loadType = Resource::feeHighBurdenRPC;
Ledger::pointer lSnapShot = boost::make_shared<Ledger> (boost::ref (*lpLedger), false);
masterLockHolder.unlock (); // As long as we have a locked copy of the ledger, we can unlock.
@@ -1730,9 +1735,9 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
// tx_json: <object>,
// secret: <secret>
// }
Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doSign (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
*loadType = LT_RPCBurden;
loadType = Resource::feeHighBurdenRPC;
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
return transactionSign (params, false, bFailHard, masterLockHolder);
}
@@ -1741,8 +1746,10 @@ Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, Applicat
// tx_json: <object>,
// secret: <secret>
// }
Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
loadType = Resource::feeMediumBurdenRPC;
if (!params.isMember ("tx_blob"))
{
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
@@ -1758,7 +1765,6 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Applic
return rpcError (rpcINVALID_PARAMS);
}
*loadType = LT_RPCBurden;
Serializer sTrans (vucBlob);
SerializerIterator sitTrans (sTrans);
@@ -1834,7 +1840,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Applic
}
}
Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doConsensusInfo (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1843,7 +1849,7 @@ Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Applic
return ret;
}
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
@@ -1860,7 +1866,7 @@ Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, LoadType* loadType, A
return ret;
}
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doServerInfo (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1869,7 +1875,7 @@ Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, Applicati
return ret;
}
Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doServerState (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1881,8 +1887,9 @@ Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, Applicat
// {
// start: <index>
// }
Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doTxHistory (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
loadType = Resource::feeMediumBurdenRPC;
masterLockHolder.unlock ();
if (!params.isMember ("start"))
@@ -1922,7 +1929,7 @@ Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, App
// {
// transaction: <hex>
// }
Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
@@ -1990,7 +1997,7 @@ Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, Applicatio
return rpcError (rpcNOT_IMPL);
}
Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedgerClosed (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -2003,7 +2010,7 @@ Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, Applica
return jvResult;
}
Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedgerCurrent (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -2017,7 +2024,7 @@ Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Applic
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
// full: true | false // optional, defaults to false.
// }
Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedger (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("ledger") && !params.isMember ("ledger_hash") && !params.isMember ("ledger_index"))
{
@@ -2050,10 +2057,14 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Applic
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
| (bAccounts ? LEDGER_JSON_DUMP_STATE : 0);
if ((bFull || bAccounts) && getApp().getFeeTrack().isLoadedLocal() && (mRole != Config::ADMIN))
if (bFull || bAccounts)
{
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
return rpcError(rpcTOO_BUSY);
if (getApp().getFeeTrack().isLoadedLocal() && (mRole != Config::ADMIN))
{
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
return rpcError(rpcTOO_BUSY);
}
loadType = Resource::feeHighBurdenRPC;
}
@@ -2064,7 +2075,7 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Applic
}
// Temporary switching code until the old account_tx is removed
Json::Value RPCHandler::doAccountTxSwitch (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountTxSwitch (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (params.isMember("offset") || params.isMember("count") || params.isMember("descending") ||
params.isMember("ledger_max") || params.isMember("ledger_min"))
@@ -2082,7 +2093,7 @@ Json::Value RPCHandler::doAccountTxSwitch (Json::Value params, LoadType* loadTyp
// offset: integer, // optional, defaults to 0
// limit: integer // optional
// }
Json::Value RPCHandler::doAccountTxOld (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raAccount;
uint32 offset = params.isMember ("offset") ? params["offset"].asUInt () : 0;
@@ -2102,6 +2113,8 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, LoadType* loadType,
if (!raAccount.setAccountID (params["account"].asString ()))
return rpcError (rpcACT_MALFORMED);
loadType = Resource::feeHighBurdenRPC;
// DEPRECATED
if (params.isMember ("ledger_min"))
{
@@ -2231,7 +2244,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, LoadType* loadType,
// limit: integer, // optional
// marker: opaque // optional, resume previous query
// }
Json::Value RPCHandler::doAccountTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raAccount;
int limit = params.isMember ("limit") ? params["limit"].asUInt () : -1;
@@ -2255,6 +2268,8 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, LoadType* loadType, App
if (!raAccount.setAccountID (params["account"].asString ()))
return rpcError (rpcACT_MALFORMED);
loadType = Resource::feeMediumBurdenRPC;
if (params.isMember ("ledger_index_min") || params.isMember ("ledger_index_max"))
{
int64 iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1;
@@ -2364,7 +2379,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, LoadType* loadType, App
// }
//
// This command requires Config::ADMIN access because it makes no sense to ask an untrusted server for this.
Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doValidationCreate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raSeed;
Json::Value obj (Json::objectValue);
@@ -2390,7 +2405,7 @@ Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadTy
// {
// secret: <string>
// }
Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doValidationSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value obj (Json::objectValue);
@@ -2461,7 +2476,7 @@ Json::Value RPCHandler::accounts (Ledger::ref lrLedger, const RippleAddress& naM
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doWalletAccounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -2504,7 +2519,7 @@ Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType
}
}
Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLogRotate (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
return LogSink::get()->rotateLog ();
}
@@ -2512,7 +2527,7 @@ Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, Applicatio
// {
// passphrase: <string>
// }
Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doWalletPropose (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
masterLockHolder.unlock ();
@@ -2544,7 +2559,7 @@ Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType,
// {
// secret: <string>
// }
Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doWalletSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raSeed;
bool bSecret = params.isMember ("secret");
@@ -2583,7 +2598,7 @@ Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Ap
// username: <string>,
// password: <string>
// }
Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLogin (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("username")
|| !params.isMember ("password"))
@@ -2621,7 +2636,7 @@ static void textTime (std::string& text, int& seconds, const char* unitName, int
text += "s";
}
Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh)
Json::Value RPCHandler::doFeature (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh)
{
if (!params.isMember ("feature"))
{
@@ -2650,7 +2665,7 @@ Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Appli
// {
// min_count: <number> // optional, defaults to 10
// }
Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doGetCounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
int minCount = 10;
@@ -2702,7 +2717,7 @@ Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, App
return ret;
}
Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLogLevel (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
// log_level
if (!params.isMember ("severity"))
@@ -2755,7 +2770,7 @@ Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Appl
// node: <domain>|<node_public>,
// comment: <comment> // optional
// }
Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlAdd (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
std::string strNode = params.isMember ("node") ? params["node"].asString () : "";
std::string strComment = params.isMember ("comment") ? params["comment"].asString () : "";
@@ -2779,7 +2794,7 @@ Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Applic
// {
// node: <domain>|<public_key>
// }
Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlDelete (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("node"))
return rpcError (rpcINVALID_PARAMS);
@@ -2802,7 +2817,7 @@ Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, App
}
}
Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlList (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value obj (Json::objectValue);
@@ -2812,7 +2827,7 @@ Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, Application:
}
// Populate the UNL from a local validators.txt file.
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlLoad (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (getConfig ().VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (getConfig ().VALIDATORS_FILE))
{
@@ -2824,7 +2839,7 @@ Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, Application:
// Populate the UNL from ripple.com's validators.txt file.
Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlNetwork (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeNetwork ();
@@ -2832,7 +2847,7 @@ Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Ap
}
// unl_reset
Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlReset (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeReset ();
@@ -2840,14 +2855,14 @@ Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Appl
}
// unl_score
Json::Value RPCHandler::doUnlScore (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnlScore (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeScore ();
return "scoring requested";
}
Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doSMS (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("text"))
return rpcError (rpcINVALID_PARAMS);
@@ -2856,14 +2871,14 @@ Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, Applicati
return "sms dispatched";
}
Json::Value RPCHandler::doStop (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doStop (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().signalStop ();
return SYSTEM_NAME " server stopping";
}
Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedgerAccept (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -2886,7 +2901,7 @@ Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, Applica
// ledger_index : <ledger_index>
// }
// XXX In this case, not specify either ledger does not mean ledger current. It means any ledger.
Json::Value RPCHandler::doTransactionEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doTransactionEntry (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -3059,7 +3074,7 @@ Json::Value RPCHandler::lookupLedger (Json::Value params, Ledger::pointer& lpLed
// ledger_index : <ledger_index>
// ...
// }
Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -3275,7 +3290,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, A
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doLedgerHeader (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doLedgerHeader (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -3317,7 +3332,7 @@ boost::unordered_set<RippleAddress> RPCHandler::parseAccountIds (const Json::Val
return usnaResult;
}
Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
@@ -3583,6 +3598,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, App
if (bSnapshot)
{
loadType = Resource::feeMediumBurdenRPC;
Ledger::pointer lpLedger = getApp().getLedgerMaster ().getPublishedLedger ();
if (lpLedger)
{
@@ -3614,7 +3630,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, App
}
// FIXME: This leaks RPCSub objects for JSON-RPC. Shouldn't matter for anyone sane.
Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
@@ -3804,7 +3820,7 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, A
//
// JSON-RPC provides a method and an array of params. JSON-RPC is used as a transport for a command and a request object. The
// command is the method. The request object is supplied as the first element of the params.
Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value const& jvParams, int iRole, LoadType* loadType)
Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value const& jvParams, int iRole, Resource::Charge& loadType)
{
WriteLog (lsTRACE, RPCHandler) << "doRpcCommand:" << strMethod << ":" << jvParams;
@@ -3845,7 +3861,7 @@ Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value
return jvResult;
}
Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
Json::Value RPCHandler::doInternal (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
{
// Used for debug or special-purpose RPC commands
if (!params.isMember ("internal_command"))
@@ -3854,7 +3870,7 @@ Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, Appl
return RPCInternalHandler::runHandler (params["internal_command"].asString (), params["params"]);
}
Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadType* loadType)
Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resource::Charge& loadType)
{
if (iRole != Config::ADMIN)
{
@@ -4016,8 +4032,8 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
{
WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what ();
if (*loadType == LT_RPCReference)
*loadType = LT_RPCException;
if (loadType == Resource::feeReferenceRPC)
loadType = Resource::feeExceptionRPC;
return rpcError (rpcINTERNAL);
}