mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Tidy up rpc module:
* Move directory up to ripple/module/rpc * Use C++11 idioms and best practices
This commit is contained in:
committed by
Vinnie Falco
parent
27a4f44de5
commit
a23013abc1
@@ -2356,16 +2356,6 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\app\peers\UniqueNodeList.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\rpc\RPCHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\app\rpc\RPCHandler.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\rpc\RPCServerHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\app\rpc\RPCServerHandler.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\shamap\FetchPackTests.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -2745,13 +2735,17 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\overlay\impl\PeerImp.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\ErrorCodes.h">
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\ErrorCodes.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Manager.h">
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Manager.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Request.h">
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\RPCHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Tuning.h">
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\RPCServerHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Request.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Tuning.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\AccountCurrencies.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
@@ -2795,6 +2789,8 @@
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\GetCounts.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\handlers\Handlers.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\Ledger.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -2948,6 +2944,8 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Authorize.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Context.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\DoPrint.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\ErrorCodes.cpp">
|
||||
@@ -2958,6 +2956,11 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\GetMasterGenerator.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\Handler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Handler.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\LegacyPathFind.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -2976,6 +2979,12 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\ParseAccountIds.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\RPCHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\RPCServerHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\TransactionSign.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
||||
@@ -391,9 +391,6 @@
|
||||
<Filter Include="ripple\module\app\peers">
|
||||
<UniqueIdentifier>{08C8AFC4-AE5D-8717-F687-1E7D1900FCC2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\module\app\rpc">
|
||||
<UniqueIdentifier>{7C2C3FCE-2F25-2E20-1290-AC9FE4811E8B}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\module\app\shamap">
|
||||
<UniqueIdentifier>{024841C2-163A-155B-A20F-51C5DB694C18}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -448,9 +445,6 @@
|
||||
<Filter Include="ripple\module\rpc">
|
||||
<UniqueIdentifier>{4DB18141-EDCD-D13F-A8D3-407F5EF72217}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\module\rpc\api">
|
||||
<UniqueIdentifier>{4FED3B95-6B6D-46D5-D2B8-A1ECC581D5AC}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ripple\module\rpc\handlers">
|
||||
<UniqueIdentifier>{9AF7847B-DAB4-9AAA-9CCD-0162235C1FEC}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -3423,18 +3417,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\module\app\peers\UniqueNodeList.h">
|
||||
<Filter>ripple\module\app\peers</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\rpc\RPCHandler.cpp">
|
||||
<Filter>ripple\module\app\rpc</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\app\rpc\RPCHandler.h">
|
||||
<Filter>ripple\module\app\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\rpc\RPCServerHandler.cpp">
|
||||
<Filter>ripple\module\app\rpc</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\app\rpc\RPCServerHandler.h">
|
||||
<Filter>ripple\module\app\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\app\shamap\FetchPackTests.cpp">
|
||||
<Filter>ripple\module\app\shamap</Filter>
|
||||
</ClCompile>
|
||||
@@ -3897,17 +3879,23 @@
|
||||
<ClInclude Include="..\..\src\ripple\module\overlay\impl\PeerImp.h">
|
||||
<Filter>ripple\module\overlay\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\ErrorCodes.h">
|
||||
<Filter>ripple\module\rpc\api</Filter>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\ErrorCodes.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Manager.h">
|
||||
<Filter>ripple\module\rpc\api</Filter>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Manager.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Request.h">
|
||||
<Filter>ripple\module\rpc\api</Filter>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\RPCHandler.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\api\Tuning.h">
|
||||
<Filter>ripple\module\rpc\api</Filter>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\RPCServerHandler.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Request.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\Tuning.h">
|
||||
<Filter>ripple\module\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\AccountCurrencies.cpp">
|
||||
<Filter>ripple\module\rpc\handlers</Filter>
|
||||
@@ -3951,6 +3939,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\GetCounts.cpp">
|
||||
<Filter>ripple\module\rpc\handlers</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\handlers\Handlers.h">
|
||||
<Filter>ripple\module\rpc\handlers</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\handlers\Ledger.cpp">
|
||||
<Filter>ripple\module\rpc\handlers</Filter>
|
||||
</ClCompile>
|
||||
@@ -4107,6 +4098,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Authorize.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Context.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\DoPrint.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
@@ -4119,6 +4113,12 @@
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\GetMasterGenerator.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\Handler.cpp">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\Handler.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\LegacyPathFind.cpp">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -4140,6 +4140,12 @@
|
||||
<ClInclude Include="..\..\src\ripple\module\rpc\impl\ParseAccountIds.h">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\RPCHandler.cpp">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\RPCServerHandler.cpp">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\module\rpc\impl\TransactionSign.cpp">
|
||||
<Filter>ripple\module\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -17,20 +17,21 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <beast/asio/io_latency_probe.h>
|
||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||
#include <ripple/basics/utility/Sustain.h>
|
||||
#include <ripple/common/seconds_clock.h>
|
||||
#include <ripple/module/app/main/Tuning.h>
|
||||
#include <ripple/module/app/misc/ProofOfWorkFactory.h>
|
||||
#include <ripple/module/overlay/api/make_Overlay.h>
|
||||
#include <ripple/module/rpc/api/Manager.h>
|
||||
#include <ripple/module/rpc/api/Manager.h>
|
||||
#include <ripple/module/rpc/Manager.h>
|
||||
#include <ripple/module/rpc/Manager.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <beast/asio/io_latency_probe.h>
|
||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO TODO Clean this global up
|
||||
|
||||
@@ -58,7 +58,7 @@ void startServer ()
|
||||
if (!getConfig ().QUIET)
|
||||
Log::out() << "Startup RPC: " << jvCommand;
|
||||
|
||||
RPCHandler rhHandler (&getApp().getOPs ());
|
||||
RPCHandler rhHandler (getApp().getOPs ());
|
||||
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
Json::Value jvResult = rhHandler.doCommand (jvCommand, Config::ADMIN, loadType);
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/module/app/rpc/RPCHandler.h>
|
||||
#include <ripple/module/app/rpc/RPCServerHandler.h>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/common/RippleSSLContext.h>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/module/rpc/RPCHandler.h>
|
||||
#include <ripple/module/rpc/RPCServerHandler.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
|
||||
m_journal.debug << "Query: " << strMethod << params;
|
||||
|
||||
RPCHandler rpcHandler (&m_networkOPs);
|
||||
RPCHandler rpcHandler (m_networkOPs);
|
||||
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
|
||||
|
||||
@@ -1,285 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
#include <ripple/module/app/rpc/RPCHandler.h>
|
||||
#include <ripple/module/app/rpc/RPCServerHandler.h>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
//
|
||||
// Carries out the RPC.
|
||||
//
|
||||
|
||||
SETUP_LOG (RPCHandler)
|
||||
|
||||
RPCHandler::RPCHandler (NetworkOPs* netOps)
|
||||
: mNetOps (netOps)
|
||||
, mRole (Config::FORBID)
|
||||
{
|
||||
}
|
||||
|
||||
RPCHandler::RPCHandler (NetworkOPs* netOps, InfoSub::pointer infoSub)
|
||||
: mNetOps (netOps)
|
||||
, mInfoSub (infoSub)
|
||||
, mRole (Config::FORBID)
|
||||
{
|
||||
}
|
||||
|
||||
// Provide the JSON-RPC "result" value.
|
||||
//
|
||||
// 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, Resource::Charge& loadType)
|
||||
{
|
||||
WriteLog (lsTRACE, RPCHandler) << "doRpcCommand:" << strMethod << ":" << jvParams;
|
||||
|
||||
if (!jvParams.isArray () || jvParams.size () > 1)
|
||||
return logRPCError (rpcError (rpcINVALID_PARAMS));
|
||||
|
||||
Json::Value params = jvParams.size () ? jvParams[0u] : Json::Value (Json::objectValue);
|
||||
|
||||
if (!params.isObject ())
|
||||
return logRPCError (rpcError (rpcINVALID_PARAMS));
|
||||
|
||||
// Provide the JSON-RPC method as the field "command" in the request.
|
||||
params[jss::command] = strMethod;
|
||||
|
||||
Json::Value jvResult = doCommand (params, iRole, loadType);
|
||||
|
||||
// Always report "status". On an error report the request as received.
|
||||
if (jvResult.isMember ("error"))
|
||||
{
|
||||
jvResult[jss::status] = jss::error;
|
||||
jvResult[jss::request] = params;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult[jss::status] = jss::success;
|
||||
}
|
||||
|
||||
return logRPCError (jvResult);
|
||||
}
|
||||
|
||||
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"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
return RPCInternalHandler::runHandler (params["internal_command"].asString (), params["params"]);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resource::Charge& loadType)
|
||||
{
|
||||
if (iRole != Config::ADMIN)
|
||||
{
|
||||
// VFALCO NOTE Should we also add up the jtRPC jobs?
|
||||
//
|
||||
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
|
||||
if (jc > 500)
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "Too busy for command: " << jc;
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.isMember ("command"))
|
||||
return rpcError (rpcCOMMAND_MISSING);
|
||||
|
||||
std::string strCommand = params[jss::command].asString ();
|
||||
|
||||
WriteLog (lsTRACE, RPCHandler) << "COMMAND:" << strCommand;
|
||||
WriteLog (lsTRACE, RPCHandler) << "REQUEST:" << params;
|
||||
|
||||
mRole = iRole;
|
||||
|
||||
static struct
|
||||
{
|
||||
const char* pCommand;
|
||||
doFuncPtr dfpFunc;
|
||||
bool bAdminRequired;
|
||||
unsigned int iOptions;
|
||||
} commandsA[] =
|
||||
{
|
||||
// Request-response methods
|
||||
{ "account_info", &RPCHandler::doAccountInfo, false, optCurrent },
|
||||
{ "account_currencies", &RPCHandler::doAccountCurrencies, false, optCurrent },
|
||||
{ "account_lines", &RPCHandler::doAccountLines, false, optCurrent },
|
||||
{ "account_offers", &RPCHandler::doAccountOffers, false, optCurrent },
|
||||
{ "account_tx", &RPCHandler::doAccountTxSwitch, false, optNetwork },
|
||||
{ "blacklist", &RPCHandler::doBlackList, true, optNone },
|
||||
{ "book_offers", &RPCHandler::doBookOffers, false, optCurrent },
|
||||
{ "connect", &RPCHandler::doConnect, true, optNone },
|
||||
{ "consensus_info", &RPCHandler::doConsensusInfo, true, optNone },
|
||||
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
||||
{ "internal", &RPCHandler::doInternal, true, optNone },
|
||||
{ "feature", &RPCHandler::doFeature, true, optNone },
|
||||
{ "fetch_info", &RPCHandler::doFetchInfo, true, optNone },
|
||||
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, true, optCurrent },
|
||||
{ "ledger_cleaner", &RPCHandler::doLedgerCleaner, true, optNetwork },
|
||||
{ "ledger_closed", &RPCHandler::doLedgerClosed, false, optClosed },
|
||||
{ "ledger_current", &RPCHandler::doLedgerCurrent, false, optCurrent },
|
||||
{ "ledger_data", &RPCHandler::doLedgerData, false, optCurrent },
|
||||
{ "ledger_entry", &RPCHandler::doLedgerEntry, false, optCurrent },
|
||||
{ "ledger_header", &RPCHandler::doLedgerHeader, false, optCurrent },
|
||||
{ "ledger_request", &RPCHandler::doLedgerRequest, true, optNone },
|
||||
{ "log_level", &RPCHandler::doLogLevel, true, optNone },
|
||||
{ "logrotate", &RPCHandler::doLogRotate, true, optNone },
|
||||
// { "nickname_info", &RPCHandler::doNicknameInfo, false, optCurrent },
|
||||
{ "owner_info", &RPCHandler::doOwnerInfo, false, optCurrent },
|
||||
{ "peers", &RPCHandler::doPeers, true, optNone },
|
||||
{ "path_find", &RPCHandler::doPathFind, false, optCurrent },
|
||||
{ "ping", &RPCHandler::doPing, false, optNone },
|
||||
{ "print", &RPCHandler::doPrint, true, optNone },
|
||||
// { "profile", &RPCHandler::doProfile, false, optCurrent },
|
||||
{ "proof_create", &RPCHandler::doProofCreate, true, optNone },
|
||||
{ "proof_solve", &RPCHandler::doProofSolve, true, optNone },
|
||||
{ "proof_verify", &RPCHandler::doProofVerify, true, optNone },
|
||||
{ "random", &RPCHandler::doRandom, false, optNone },
|
||||
{ "ripple_path_find", &RPCHandler::doRipplePathFind, false, optCurrent },
|
||||
{ "sign", &RPCHandler::doSign, false, optNone },
|
||||
{ "submit", &RPCHandler::doSubmit, false, optCurrent },
|
||||
{ "server_info", &RPCHandler::doServerInfo, false, optNone },
|
||||
{ "server_state", &RPCHandler::doServerState, false, optNone },
|
||||
{ "sms", &RPCHandler::doSMS, true, optNone },
|
||||
{ "stop", &RPCHandler::doStop, true, optNone },
|
||||
{ "transaction_entry", &RPCHandler::doTransactionEntry, false, optCurrent },
|
||||
{ "tx", &RPCHandler::doTx, false, optNetwork },
|
||||
{ "tx_history", &RPCHandler::doTxHistory, false, optNone },
|
||||
{ "unl_add", &RPCHandler::doUnlAdd, true, optNone },
|
||||
{ "unl_delete", &RPCHandler::doUnlDelete, true, optNone },
|
||||
{ "unl_list", &RPCHandler::doUnlList, true, optNone },
|
||||
{ "unl_load", &RPCHandler::doUnlLoad, true, optNone },
|
||||
{ "unl_network", &RPCHandler::doUnlNetwork, true, optNone },
|
||||
{ "unl_reset", &RPCHandler::doUnlReset, true, optNone },
|
||||
{ "unl_score", &RPCHandler::doUnlScore, true, optNone },
|
||||
{ "validation_create", &RPCHandler::doValidationCreate, true, optNone },
|
||||
{ "validation_seed", &RPCHandler::doValidationSeed, true, optNone },
|
||||
{ "wallet_accounts", &RPCHandler::doWalletAccounts, false, optCurrent },
|
||||
{ "wallet_propose", &RPCHandler::doWalletPropose, true, optNone },
|
||||
{ "wallet_seed", &RPCHandler::doWalletSeed, true, optNone },
|
||||
|
||||
// Evented methods
|
||||
{ "subscribe", &RPCHandler::doSubscribe, false, optNone },
|
||||
{ "unsubscribe", &RPCHandler::doUnsubscribe, false, optNone },
|
||||
};
|
||||
|
||||
int i = RIPPLE_ARRAYSIZE (commandsA);
|
||||
|
||||
while (i-- && strCommand != commandsA[i].pCommand)
|
||||
;
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
return rpcError (rpcUNKNOWN_COMMAND);
|
||||
}
|
||||
else if (commandsA[i].bAdminRequired && mRole != Config::ADMIN)
|
||||
{
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
}
|
||||
|
||||
{
|
||||
Application::ScopedLockType lock (getApp().getMasterLock ());
|
||||
|
||||
if ((commandsA[i].iOptions & optNetwork) && (mNetOps->getOperatingMode () < NetworkOPs::omSYNCING))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Insufficient network mode for RPC: " << mNetOps->strOperatingMode ();
|
||||
|
||||
return rpcError (rpcNO_NETWORK);
|
||||
}
|
||||
|
||||
if (!getConfig ().RUN_STANDALONE && (commandsA[i].iOptions & optCurrent) && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
|
||||
{
|
||||
return rpcError (rpcNO_CURRENT);
|
||||
}
|
||||
else if ((commandsA[i].iOptions & optClosed) && !mNetOps->getClosedLedger ())
|
||||
{
|
||||
return rpcError (rpcNO_CLOSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadEvent::autoptr ev = getApp().getJobQueue().getLoadEventAP(
|
||||
jtGENERIC, std::string("cmd:") + strCommand);
|
||||
Json::Value jvRaw = (this->* (commandsA[i].dfpFunc)) (params, loadType, lock);
|
||||
|
||||
// Regularize result.
|
||||
if (jvRaw.isObject ())
|
||||
{
|
||||
// Got an object.
|
||||
return jvRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably got a string.
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult[jss::message] = jvRaw;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what ();
|
||||
|
||||
if (loadType == Resource::feeReferenceRPC)
|
||||
loadType = Resource::feeExceptionRPC;
|
||||
|
||||
return rpcError (rpcINTERNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RPCInternalHandler* RPCInternalHandler::sHeadHandler = nullptr;
|
||||
|
||||
RPCInternalHandler::RPCInternalHandler (const std::string& name, handler_t Handler) : mName (name), mHandler (Handler)
|
||||
{
|
||||
mNextHandler = sHeadHandler;
|
||||
sHeadHandler = this;
|
||||
}
|
||||
|
||||
Json::Value RPCInternalHandler::runHandler (const std::string& name, const Json::Value& params)
|
||||
{
|
||||
RPCInternalHandler* h = sHeadHandler;
|
||||
|
||||
while (h != nullptr)
|
||||
{
|
||||
if (name == h->mName)
|
||||
{
|
||||
WriteLog (lsWARNING, RPCHandler) << "Internal command " << name << ": " << params;
|
||||
Json::Value ret = h->mHandler (params);
|
||||
WriteLog (lsWARNING, RPCHandler) << "Internal command returns: " << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
h = h->mNextHandler;
|
||||
}
|
||||
|
||||
return rpcError (rpcBAD_SYNTAX);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
@@ -1,166 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_APP_RPC_HANDLER
|
||||
#define RIPPLE_APP_RPC_HANDLER
|
||||
|
||||
#include <ripple/module/rpc/impl/AccountFromString.h>
|
||||
#include <ripple/module/rpc/impl/Accounts.h>
|
||||
#include <ripple/module/rpc/impl/Authorize.h>
|
||||
#include <ripple/module/rpc/impl/GetMasterGenerator.h>
|
||||
#include <ripple/module/rpc/impl/LookupLedger.h>
|
||||
#include <ripple/module/rpc/impl/ParseAccountIds.h>
|
||||
#include <ripple/module/rpc/impl/TransactionSign.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// used by the RPCServer or WSDoor to carry out these RPC commands
|
||||
class NetworkOPs;
|
||||
class InfoSub;
|
||||
|
||||
// VFALCO TODO Refactor to abstract interface IRPCHandler
|
||||
//
|
||||
|
||||
class RPCHandler
|
||||
{
|
||||
public:
|
||||
explicit RPCHandler (NetworkOPs* netOps);
|
||||
|
||||
RPCHandler (NetworkOPs* netOps, InfoSub::pointer infoSub);
|
||||
|
||||
Json::Value doCommand (const Json::Value& jvRequest, int role, Resource::Charge& loadType);
|
||||
|
||||
Json::Value doRpcCommand (const std::string& strCommand, Json::Value const& jvParams, int iRole, Resource::Charge& loadType);
|
||||
|
||||
private:
|
||||
typedef Json::Value (RPCHandler::*doFuncPtr) (
|
||||
Json::Value params,
|
||||
Resource::Charge& loadType,
|
||||
Application::ScopedLockType& MasterLockHolder);
|
||||
|
||||
// VFALCO TODO Document these and give the enumeration a label.
|
||||
enum
|
||||
{
|
||||
optNone = 0,
|
||||
optNetwork = 1, // Need network
|
||||
optCurrent = 2 + optNetwork, // Need current ledger
|
||||
optClosed = 4 + optNetwork, // Need closed ledger
|
||||
};
|
||||
|
||||
// Utilities
|
||||
|
||||
Json::Value doAccountCurrencies (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountLines (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountTxSwitch (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doAccountTxOld (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doBookOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doBlackList (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doConnect (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doConsensusInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doFeature (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doFetchInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doGetCounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doInternal (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedger (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerAccept (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerCleaner (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerClosed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerCurrent (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerData (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerEntry (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerHeader (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLedgerRequest (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLogLevel (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doLogRotate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doNicknameInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doOwnerInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPathFind (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPeers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPing (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doPrint (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProfile (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofCreate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofSolve (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doProofVerify (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doRandom (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doRipplePathFind (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSMS (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doServerInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh); // for humans
|
||||
Json::Value doServerState (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh); // for machines
|
||||
Json::Value doSessionClose (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSessionOpen (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSign (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doStop (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSubmit (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doSubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTransactionEntry (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doTxHistory (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlAdd (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlDelete (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlFetch (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlList (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlLoad (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlNetwork (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlReset (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnlScore (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doUnsubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doValidationCreate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doValidationSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletAccounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletLock (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletPropose (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletUnlock (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
Json::Value doWalletVerify (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh);
|
||||
|
||||
private:
|
||||
NetworkOPs* mNetOps;
|
||||
InfoSub::pointer mInfoSub;
|
||||
|
||||
// VFALCO TODO Create an enumeration for this.
|
||||
int mRole;
|
||||
};
|
||||
|
||||
class RPCInternalHandler
|
||||
{
|
||||
public:
|
||||
typedef Json::Value (*handler_t) (const Json::Value&);
|
||||
|
||||
public:
|
||||
RPCInternalHandler (const std::string& name, handler_t handler);
|
||||
static Json::Value runHandler (const std::string& name, const Json::Value& params);
|
||||
|
||||
private:
|
||||
// VFALCO TODO Replace with a singleton with a well defined interface and
|
||||
// a lock free stack (if necessary).
|
||||
//
|
||||
static RPCInternalHandler* sHeadHandler;
|
||||
|
||||
RPCInternalHandler* mNextHandler;
|
||||
std::string mName;
|
||||
handler_t mHandler;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -154,7 +154,7 @@ Json::Value WSConnection::invokeCommand (Json::Value& jvRequest)
|
||||
}
|
||||
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
RPCHandler mRPCHandler (&this->m_netOPs, std::dynamic_pointer_cast<InfoSub> (this->shared_from_this ()));
|
||||
RPCHandler mRPCHandler (m_netOPs, std::dynamic_pointer_cast<InfoSub> (this->shared_from_this ()));
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
Config::Role const role = m_isPublic
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_WSSERVERHANDLER_H_INCLUDED
|
||||
#define RIPPLE_WSSERVERHANDLER_H_INCLUDED
|
||||
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
#include <ripple/module/app/websocket/WSConnection.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_RPC_MANAGER_H_INCLUDED
|
||||
#define RIPPLE_RPC_MANAGER_H_INCLUDED
|
||||
|
||||
#include <ripple/module/rpc/api/Request.h>
|
||||
#include <ripple/module/rpc/Request.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
84
src/ripple/module/rpc/RPCHandler.h
Normal file
84
src/ripple/module/rpc/RPCHandler.h
Normal file
@@ -0,0 +1,84 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_APP_RPC_HANDLER
|
||||
#define RIPPLE_APP_RPC_HANDLER
|
||||
|
||||
#include <ripple/module/rpc/impl/AccountFromString.h>
|
||||
#include <ripple/module/rpc/impl/Accounts.h>
|
||||
#include <ripple/module/rpc/impl/Authorize.h>
|
||||
#include <ripple/module/rpc/impl/Context.h>
|
||||
#include <ripple/module/rpc/impl/GetMasterGenerator.h>
|
||||
#include <ripple/module/rpc/impl/LookupLedger.h>
|
||||
#include <ripple/module/rpc/impl/ParseAccountIds.h>
|
||||
#include <ripple/module/rpc/impl/TransactionSign.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// used by the RPCServer or WSDoor to carry out these RPC commands
|
||||
class NetworkOPs;
|
||||
class InfoSub;
|
||||
|
||||
class RPCHandler
|
||||
{
|
||||
public:
|
||||
explicit RPCHandler (NetworkOPs& netOps);
|
||||
|
||||
RPCHandler (NetworkOPs& netOps, InfoSub::pointer infoSub);
|
||||
|
||||
Json::Value doCommand (
|
||||
const Json::Value& jvRequest, Config::Role role,
|
||||
Resource::Charge& loadType);
|
||||
|
||||
Json::Value doRpcCommand (
|
||||
const std::string& strCommand, Json::Value const& jvParams,
|
||||
Config::Role iRole, Resource::Charge& loadType);
|
||||
|
||||
// Utilities
|
||||
|
||||
private:
|
||||
NetworkOPs* mNetOps;
|
||||
InfoSub::pointer mInfoSub;
|
||||
|
||||
Config::Role mRole;
|
||||
};
|
||||
|
||||
class RPCInternalHandler
|
||||
{
|
||||
public:
|
||||
typedef Json::Value (*handler_t) (const Json::Value&);
|
||||
|
||||
public:
|
||||
RPCInternalHandler (const std::string& name, handler_t handler);
|
||||
static Json::Value runHandler (const std::string& name, const Json::Value& params);
|
||||
|
||||
private:
|
||||
// VFALCO TODO Replace with a singleton with a well defined interface and
|
||||
// a lock free stack (if necessary).
|
||||
//
|
||||
static RPCInternalHandler* sHeadHandler;
|
||||
|
||||
RPCInternalHandler* mNextHandler;
|
||||
std::string mName;
|
||||
handler_t mHandler;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -19,32 +19,32 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doAccountCurrencies (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountCurrencies (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
// Get the current ledger
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult (RPC::lookupLedger (params, lpLedger, *mNetOps));
|
||||
Json::Value jvResult (RPC::lookupLedger (context.params_, lpLedger, context.netOps_));
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (! params.isMember ("account") && ! params.isMember ("ident"))
|
||||
if (! context.params_.isMember ("account") && ! context.params_.isMember ("ident"))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string const strIdent (params.isMember ("account")
|
||||
? params["account"].asString ()
|
||||
: params["ident"].asString ());
|
||||
std::string const strIdent (context.params_.isMember ("account")
|
||||
? context.params_["account"].asString ()
|
||||
: context.params_["ident"].asString ());
|
||||
|
||||
int const iIndex (params.isMember ("account_index")
|
||||
? params["account_index"].asUInt ()
|
||||
int const iIndex (context.params_.isMember ("account_index")
|
||||
? context.params_["account_index"].asUInt ()
|
||||
: 0);
|
||||
bool const bStrict (params.isMember ("strict") && params["strict"].asBool ());
|
||||
bool const bStrict (context.params_.isMember ("strict") && context.params_["strict"].asBool ());
|
||||
|
||||
// Get info on account.
|
||||
bool bIndex; // out param
|
||||
RippleAddress naAccount; // out param
|
||||
Json::Value jvAccepted (RPC::accountFromString (
|
||||
lpLedger, naAccount, bIndex, strIdent, iIndex, bStrict, *mNetOps));
|
||||
lpLedger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_));
|
||||
|
||||
if (!jvAccepted.empty ())
|
||||
return jvAccepted;
|
||||
|
||||
@@ -26,33 +26,33 @@ namespace ripple {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountInfo (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember ("account") && !params.isMember ("ident"))
|
||||
if (!context.params_.isMember ("account") && !context.params_.isMember ("ident"))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params.isMember ("account") ? params["account"].asString () : params["ident"].asString ();
|
||||
std::string strIdent = context.params_.isMember ("account") ? context.params_["account"].asString () : context.params_["ident"].asString ();
|
||||
bool bIndex;
|
||||
int iIndex = params.isMember ("account_index") ? params["account_index"].asUInt () : 0;
|
||||
bool bStrict = params.isMember ("strict") && params["strict"].asBool ();
|
||||
int iIndex = context.params_.isMember ("account_index") ? context.params_["account_index"].asUInt () : 0;
|
||||
bool bStrict = context.params_.isMember ("strict") && context.params_["strict"].asBool ();
|
||||
RippleAddress naAccount;
|
||||
|
||||
// Get info on account.
|
||||
|
||||
Json::Value jvAccepted = RPC::accountFromString (lpLedger, naAccount, bIndex, strIdent, iIndex, bStrict, *mNetOps);
|
||||
Json::Value jvAccepted = RPC::accountFromString (lpLedger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_);
|
||||
|
||||
if (!jvAccepted.empty ())
|
||||
return jvAccepted;
|
||||
|
||||
AccountState::pointer asAccepted = mNetOps->getAccountState (lpLedger, naAccount);
|
||||
AccountState::pointer asAccepted = context.netOps_.getAccountState (lpLedger, naAccount);
|
||||
|
||||
if (asAccepted)
|
||||
{
|
||||
|
||||
@@ -26,33 +26,33 @@ namespace ripple {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountLines (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember (jss::account))
|
||||
if (!context.params_.isMember (jss::account))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params[jss::account].asString ();
|
||||
bool bIndex = params.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? params[jss::account_index].asUInt () : 0;
|
||||
std::string strIdent = context.params_[jss::account].asString ();
|
||||
bool bIndex = context.params_.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? context.params_[jss::account_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raAccount;
|
||||
|
||||
jvResult = RPC::accountFromString (lpLedger, raAccount, bIndex, strIdent, iIndex, false, *mNetOps);
|
||||
jvResult = RPC::accountFromString (lpLedger, raAccount, bIndex, strIdent, iIndex, false, context.netOps_);
|
||||
|
||||
if (!jvResult.empty ())
|
||||
return jvResult;
|
||||
|
||||
std::string strPeer = params.isMember (jss::peer) ? params[jss::peer].asString () : "";
|
||||
bool bPeerIndex = params.isMember (jss::peer_index);
|
||||
int iPeerIndex = bIndex ? params[jss::peer_index].asUInt () : 0;
|
||||
std::string strPeer = context.params_.isMember (jss::peer) ? context.params_[jss::peer].asString () : "";
|
||||
bool bPeerIndex = context.params_.isMember (jss::peer_index);
|
||||
int iPeerIndex = bIndex ? context.params_[jss::peer_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raPeer;
|
||||
|
||||
@@ -63,7 +63,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
if (bPeerIndex)
|
||||
jvResult[jss::peer_index] = iPeerIndex;
|
||||
|
||||
jvResult = RPC::accountFromString (lpLedger, raPeer, bPeerIndex, strPeer, iPeerIndex, false, *mNetOps);
|
||||
jvResult = RPC::accountFromString (lpLedger, raPeer, bPeerIndex, strPeer, iPeerIndex, false, context.netOps_);
|
||||
|
||||
if (!jvResult.empty ())
|
||||
return jvResult;
|
||||
@@ -109,7 +109,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, Resource::Charge& lo
|
||||
}
|
||||
}
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -38,26 +38,26 @@ static void offerAdder (Json::Value& jvLines, SLE::ref offer)
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountOffers (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember (jss::account))
|
||||
if (!context.params_.isMember (jss::account))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params[jss::account].asString ();
|
||||
bool bIndex = params.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? params[jss::account_index].asUInt () : 0;
|
||||
std::string strIdent = context.params_[jss::account].asString ();
|
||||
bool bIndex = context.params_.isMember (jss::account_index);
|
||||
int iIndex = bIndex ? context.params_[jss::account_index].asUInt () : 0;
|
||||
|
||||
RippleAddress raAccount;
|
||||
|
||||
jvResult = RPC::accountFromString (lpLedger, raAccount, bIndex, strIdent, iIndex, false, *mNetOps);
|
||||
jvResult = RPC::accountFromString (lpLedger, raAccount, bIndex, strIdent, iIndex, false, context.netOps_);
|
||||
|
||||
if (!jvResult.empty ())
|
||||
return jvResult;
|
||||
@@ -77,7 +77,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& l
|
||||
std::bind (&offerAdder, std::ref (jvsOffers),
|
||||
std::placeholders::_1));
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -29,19 +29,19 @@ namespace ripple {
|
||||
// limit: integer, // optional
|
||||
// marker: opaque // optional, resume previous query
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountTx (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
RippleAddress raAccount;
|
||||
int limit = params.isMember (jss::limit) ? params[jss::limit].asUInt () : -1;
|
||||
bool bBinary = params.isMember ("binary") && params["binary"].asBool ();
|
||||
bool bForward = params.isMember ("forward") && params["forward"].asBool ();
|
||||
int limit = context.params_.isMember (jss::limit) ? context.params_[jss::limit].asUInt () : -1;
|
||||
bool bBinary = context.params_.isMember ("binary") && context.params_["binary"].asBool ();
|
||||
bool bForward = context.params_.isMember ("forward") && context.params_["forward"].asBool ();
|
||||
std::uint32_t uLedgerMin;
|
||||
std::uint32_t uLedgerMax;
|
||||
std::uint32_t uValidatedMin;
|
||||
std::uint32_t uValidatedMax;
|
||||
bool bValidated = mNetOps->getValidatedRange (uValidatedMin, uValidatedMax);
|
||||
bool bValidated = context.netOps_.getValidatedRange (uValidatedMin, uValidatedMax);
|
||||
|
||||
if (!bValidated)
|
||||
{
|
||||
@@ -49,18 +49,18 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
return rpcError (rpcLGR_IDXS_INVALID);
|
||||
}
|
||||
|
||||
if (!params.isMember ("account"))
|
||||
if (!context.params_.isMember ("account"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
if (!raAccount.setAccountID (params["account"].asString ()))
|
||||
if (!raAccount.setAccountID (context.params_["account"].asString ()))
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (params.isMember ("ledger_index_min") || params.isMember ("ledger_index_max"))
|
||||
if (context.params_.isMember ("ledger_index_min") || context.params_.isMember ("ledger_index_max"))
|
||||
{
|
||||
std::int64_t iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1;
|
||||
std::int64_t iLedgerMin = context.params_.isMember ("ledger_index_min") ? context.params_["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = context.params_.isMember ("ledger_index_max") ? context.params_["ledger_index_max"].asInt () : -1;
|
||||
|
||||
|
||||
uLedgerMin = iLedgerMin == -1 ? uValidatedMin : iLedgerMin;
|
||||
@@ -74,7 +74,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
else
|
||||
{
|
||||
Ledger::pointer l;
|
||||
Json::Value ret = RPC::lookupLedger (params, l, *mNetOps);
|
||||
Json::Value ret = RPC::lookupLedger (context.params_, l, context.netOps_);
|
||||
|
||||
if (!l)
|
||||
return ret;
|
||||
@@ -84,9 +84,9 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
Json::Value resumeToken;
|
||||
|
||||
if (params.isMember(jss::marker))
|
||||
if (context.params_.isMember(jss::marker))
|
||||
{
|
||||
resumeToken = params[jss::marker];
|
||||
resumeToken = context.params_[jss::marker];
|
||||
}
|
||||
|
||||
#ifndef BEAST_DEBUG
|
||||
@@ -102,7 +102,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
if (bBinary)
|
||||
{
|
||||
std::vector<NetworkOPs::txnMetaLedgerType> txns =
|
||||
mNetOps->getTxsAccountB (raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, mRole == Config::ADMIN);
|
||||
context.netOps_.getTxsAccountB (raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, context.role_ == Config::ADMIN);
|
||||
|
||||
for (std::vector<NetworkOPs::txnMetaLedgerType>::const_iterator it = txns.begin (), end = txns.end ();
|
||||
it != end; ++it)
|
||||
@@ -120,7 +120,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
else
|
||||
{
|
||||
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns =
|
||||
mNetOps->getTxsAccount (raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, mRole == Config::ADMIN);
|
||||
context.netOps_.getTxsAccount (raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit, context.role_ == Config::ADMIN);
|
||||
|
||||
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin (), end = txns.end (); it != end; ++it)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT
|
||||
//Add information about the original query
|
||||
ret[jss::ledger_index_min] = uLedgerMin;
|
||||
ret[jss::ledger_index_max] = uLedgerMax;
|
||||
if (params.isMember (jss::limit))
|
||||
if (context.params_.isMember (jss::limit))
|
||||
ret[jss::limit] = limit;
|
||||
if (!resumeToken.isNull())
|
||||
ret[jss::marker] = resumeToken;
|
||||
|
||||
@@ -30,51 +30,51 @@ namespace ripple {
|
||||
// offset: integer, // optional, defaults to 0
|
||||
// limit: integer // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountTxOld (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
RippleAddress raAccount;
|
||||
std::uint32_t offset = params.isMember ("offset") ? params["offset"].asUInt () : 0;
|
||||
int limit = params.isMember ("limit") ? params["limit"].asUInt () : -1;
|
||||
bool bBinary = params.isMember ("binary") && params["binary"].asBool ();
|
||||
bool bDescending = params.isMember ("descending") && params["descending"].asBool ();
|
||||
bool bCount = params.isMember ("count") && params["count"].asBool ();
|
||||
std::uint32_t offset = context.params_.isMember ("offset") ? context.params_["offset"].asUInt () : 0;
|
||||
int limit = context.params_.isMember ("limit") ? context.params_["limit"].asUInt () : -1;
|
||||
bool bBinary = context.params_.isMember ("binary") && context.params_["binary"].asBool ();
|
||||
bool bDescending = context.params_.isMember ("descending") && context.params_["descending"].asBool ();
|
||||
bool bCount = context.params_.isMember ("count") && context.params_["count"].asBool ();
|
||||
std::uint32_t uLedgerMin;
|
||||
std::uint32_t uLedgerMax;
|
||||
std::uint32_t uValidatedMin;
|
||||
std::uint32_t uValidatedMax;
|
||||
bool bValidated = mNetOps->getValidatedRange (uValidatedMin, uValidatedMax);
|
||||
bool bValidated = context.netOps_.getValidatedRange (uValidatedMin, uValidatedMax);
|
||||
|
||||
if (!params.isMember ("account"))
|
||||
if (!context.params_.isMember ("account"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
if (!raAccount.setAccountID (params["account"].asString ()))
|
||||
if (!raAccount.setAccountID (context.params_["account"].asString ()))
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
|
||||
if (offset > 3000)
|
||||
return rpcError (rpcATX_DEPRECATED);
|
||||
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
|
||||
// DEPRECATED
|
||||
if (params.isMember ("ledger_min"))
|
||||
if (context.params_.isMember ("ledger_min"))
|
||||
{
|
||||
params["ledger_index_min"] = params["ledger_min"];
|
||||
context.params_["ledger_index_min"] = context.params_["ledger_min"];
|
||||
bDescending = true;
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
if (params.isMember ("ledger_max"))
|
||||
if (context.params_.isMember ("ledger_max"))
|
||||
{
|
||||
params["ledger_index_max"] = params["ledger_max"];
|
||||
context.params_["ledger_index_max"] = context.params_["ledger_max"];
|
||||
bDescending = true;
|
||||
}
|
||||
|
||||
if (params.isMember ("ledger_index_min") || params.isMember ("ledger_index_max"))
|
||||
if (context.params_.isMember ("ledger_index_min") || context.params_.isMember ("ledger_index_max"))
|
||||
{
|
||||
std::int64_t iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1;
|
||||
std::int64_t iLedgerMin = context.params_.isMember ("ledger_index_min") ? context.params_["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = context.params_.isMember ("ledger_index_max") ? context.params_["ledger_index_max"].asInt () : -1;
|
||||
|
||||
if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1))
|
||||
{
|
||||
@@ -93,7 +93,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo
|
||||
else
|
||||
{
|
||||
Ledger::pointer l;
|
||||
Json::Value ret = RPC::lookupLedger (params, l, *mNetOps);
|
||||
Json::Value ret = RPC::lookupLedger (context.params_, l, context.netOps_);
|
||||
|
||||
if (!l)
|
||||
return ret;
|
||||
@@ -117,7 +117,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo
|
||||
if (bBinary)
|
||||
{
|
||||
std::vector<NetworkOPs::txnMetaLedgerType> txns =
|
||||
mNetOps->getAccountTxsB (raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, mRole == Config::ADMIN);
|
||||
context.netOps_.getAccountTxsB (raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, context.role_ == Config::ADMIN);
|
||||
|
||||
for (std::vector<NetworkOPs::txnMetaLedgerType>::const_iterator it = txns.begin (), end = txns.end ();
|
||||
it != end; ++it)
|
||||
@@ -135,7 +135,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs (raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, mRole == Config::ADMIN);
|
||||
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = context.netOps_.getAccountTxs (raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit, context.role_ == Config::ADMIN);
|
||||
|
||||
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin (), end = txns.end (); it != end; ++it)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo
|
||||
if (bCount)
|
||||
ret["count"] = count;
|
||||
|
||||
if (params.isMember ("limit"))
|
||||
if (context.params_.isMember ("limit"))
|
||||
ret["limit"] = limit;
|
||||
|
||||
|
||||
|
||||
@@ -20,12 +20,17 @@
|
||||
namespace ripple {
|
||||
|
||||
// Temporary switching code until the old account_tx is removed
|
||||
Json::Value RPCHandler::doAccountTxSwitch (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doAccountTxSwitch (RPC::Context& context)
|
||||
{
|
||||
if (params.isMember("offset") || params.isMember("count") || params.isMember("descending") ||
|
||||
params.isMember("ledger_max") || params.isMember("ledger_min"))
|
||||
return doAccountTxOld(params, loadType, masterLockHolder);
|
||||
return doAccountTx(params, loadType, masterLockHolder);
|
||||
if (context.params_.isMember("offset") ||
|
||||
context.params_.isMember("count") ||
|
||||
context.params_.isMember("descending") ||
|
||||
context.params_.isMember("ledger_max") ||
|
||||
context.params_.isMember("ledger_min"))
|
||||
{
|
||||
return doAccountTxOld(context);
|
||||
}
|
||||
return doAccountTx(context);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doBlackList (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doBlackList (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock();
|
||||
if (params.isMember("threshold"))
|
||||
return getApp().getResourceManager().getJson(params["threshold"].asInt());
|
||||
context.lock_.unlock();
|
||||
if (context.params_.isMember("threshold"))
|
||||
return getApp().getResourceManager().getJson(context.params_["threshold"].asInt());
|
||||
else
|
||||
return getApp().getResourceManager().getJson();
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ inline uint160 const& neutral_issuer ()
|
||||
return ACCOUNT_ONE;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doBookOffers (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
// VFALCO TODO Here is a terrible place for this kind of business
|
||||
// logic. It needs to be moved elsewhere and documented,
|
||||
@@ -57,24 +57,24 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& load
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult (RPC::lookupLedger (params, lpLedger, *mNetOps));
|
||||
Json::Value jvResult (RPC::lookupLedger (context.params_, lpLedger, context.netOps_));
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember ("taker_pays"))
|
||||
if (!context.params_.isMember ("taker_pays"))
|
||||
return RPC::missing_field_error ("taker_pays");
|
||||
|
||||
if (!params.isMember ("taker_gets"))
|
||||
if (!context.params_.isMember ("taker_gets"))
|
||||
return RPC::missing_field_error ("taker_gets");
|
||||
|
||||
if (!params["taker_pays"].isObject ())
|
||||
if (!context.params_["taker_pays"].isObject ())
|
||||
return RPC::object_field_error ("taker_pays");
|
||||
|
||||
if (!params["taker_gets"].isObject ())
|
||||
if (!context.params_["taker_gets"].isObject ())
|
||||
return RPC::object_field_error ("taker_gets");
|
||||
|
||||
Json::Value const& taker_pays (params["taker_pays"]);
|
||||
Json::Value const& taker_pays (context.params_["taker_pays"]);
|
||||
|
||||
if (!taker_pays.isMember ("currency"))
|
||||
return RPC::missing_field_error ("taker_pays.currency");
|
||||
@@ -82,7 +82,7 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& load
|
||||
if (! taker_pays ["currency"].isString ())
|
||||
return RPC::expected_field_error ("taker_pays.currency", "string");
|
||||
|
||||
Json::Value const& taker_gets = params["taker_gets"];
|
||||
Json::Value const& taker_gets = context.params_["taker_gets"];
|
||||
|
||||
if (! taker_gets.isMember ("currency"))
|
||||
return RPC::missing_field_error ("taker_gets.currency");
|
||||
@@ -171,12 +171,12 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& load
|
||||
|
||||
RippleAddress raTakerID;
|
||||
|
||||
if (params.isMember ("taker"))
|
||||
if (context.params_.isMember ("taker"))
|
||||
{
|
||||
if (! params ["taker"].isString ())
|
||||
if (! context.params_ ["taker"].isString ())
|
||||
return RPC::expected_field_error ("taker", "string");
|
||||
|
||||
if (! raTakerID.setAccountID (params ["taker"].asString ()))
|
||||
if (! raTakerID.setAccountID (context.params_ ["taker"].asString ()))
|
||||
return RPC::invalid_field_error ("taker");
|
||||
}
|
||||
else
|
||||
@@ -190,25 +190,25 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, Resource::Charge& load
|
||||
return RPC::make_error (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
if (params.isMember ("limit") && ! params ["limit"].isIntegral())
|
||||
if (context.params_.isMember ("limit") && ! context.params_ ["limit"].isIntegral())
|
||||
return RPC::expected_field_error (
|
||||
"limit", "integer");
|
||||
|
||||
unsigned int const iLimit (params.isMember ("limit")
|
||||
? params ["limit"].asUInt ()
|
||||
unsigned int const iLimit (context.params_.isMember ("limit")
|
||||
? context.params_ ["limit"].asUInt ()
|
||||
: 0);
|
||||
|
||||
bool const bProof (params.isMember ("proof"));
|
||||
bool const bProof (context.params_.isMember ("proof"));
|
||||
|
||||
Json::Value const jvMarker (params.isMember ("marker")
|
||||
? params["marker"]
|
||||
Json::Value const jvMarker (context.params_.isMember ("marker")
|
||||
? context.params_["marker"]
|
||||
: Json::Value (Json::nullValue));
|
||||
|
||||
mNetOps->getBookPage (lpLedger, pay_currency, pay_issuer,
|
||||
context.netOps_.getBookPage (lpLedger, pay_currency, pay_issuer,
|
||||
get_currency, get_issuer, raTakerID.getAccountID (),
|
||||
bProof, iLimit, jvMarker, jvResult);
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -26,27 +26,25 @@ namespace ripple {
|
||||
// port: <number>
|
||||
// }
|
||||
// XXX Might allow domain for manual connections.
|
||||
Json::Value RPCHandler::doConnect (Json::Value params,
|
||||
Resource::Charge& loadType,
|
||||
Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doConnect (RPC::Context& context)
|
||||
{
|
||||
if (getConfig ().RUN_STANDALONE)
|
||||
return "cannot connect in standalone mode";
|
||||
|
||||
if (!params.isMember ("ip"))
|
||||
if (!context.params_.isMember ("ip"))
|
||||
return RPC::missing_field_error ("ip");
|
||||
|
||||
if (params.isMember ("port") && !params["port"].isConvertibleTo (Json::intValue))
|
||||
if (context.params_.isMember ("port") && !context.params_["port"].isConvertibleTo (Json::intValue))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
int iPort;
|
||||
|
||||
if(params.isMember ("port"))
|
||||
iPort = params["port"].asInt ();
|
||||
if(context.params_.isMember ("port"))
|
||||
iPort = context.params_["port"].asInt ();
|
||||
else
|
||||
iPort = SYSTEM_PEER_PORT;
|
||||
|
||||
beast::IP::Endpoint ip (beast::IP::Endpoint::from_string(params["ip"].asString ()));
|
||||
beast::IP::Endpoint ip (beast::IP::Endpoint::from_string(context.params_["ip"].asString ()));
|
||||
|
||||
if (! is_unspecified (ip))
|
||||
getApp().overlay ().connect (ip.at_port(iPort));
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doConsensusInfo (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doConsensusInfo (RPC::Context& context)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
ret["info"] = mNetOps->getConsensusInfo ();
|
||||
ret["info"] = context.netOps_.getConsensusInfo ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -40,26 +40,26 @@ static void textTime (std::string& text, int& seconds, const char* unitName, int
|
||||
text += "s";
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doFeature (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& mlh)
|
||||
Json::Value doFeature (RPC::Context& context)
|
||||
{
|
||||
if (!params.isMember ("feature"))
|
||||
if (!context.params_.isMember ("feature"))
|
||||
{
|
||||
Json::Value jvReply = Json::objectValue;
|
||||
jvReply["features"] = getApp().getAmendmentTable ().getJson(0);
|
||||
return jvReply;
|
||||
}
|
||||
|
||||
uint256 uFeature = getApp().getAmendmentTable ().get(params["feature"].asString());
|
||||
uint256 uFeature = getApp().getAmendmentTable ().get(context.params_["feature"].asString());
|
||||
|
||||
if (uFeature.isZero ())
|
||||
{
|
||||
uFeature.SetHex (params["feature"].asString ());
|
||||
uFeature.SetHex (context.params_["feature"].asString ());
|
||||
|
||||
if (uFeature.isZero ())
|
||||
return rpcError (rpcBAD_FEATURE);
|
||||
}
|
||||
|
||||
if (!params.isMember ("vote"))
|
||||
if (!context.params_.isMember ("vote"))
|
||||
return getApp().getAmendmentTable ().getJson(uFeature);
|
||||
|
||||
// WRITEME
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doFetchInfo (Json::Value jvParams, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doFetchInfo (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
if (jvParams.isMember("clear") && jvParams["clear"].asBool())
|
||||
if (context.params_.isMember("clear") && context.params_["clear"].asBool())
|
||||
{
|
||||
mNetOps->clearLedgerFetch();
|
||||
context.netOps_.clearLedgerFetch();
|
||||
ret["clear"] = true;
|
||||
}
|
||||
|
||||
ret["info"] = mNetOps->getLedgerFetchInfo();
|
||||
ret["info"] = context.netOps_.getLedgerFetchInfo();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ namespace ripple {
|
||||
// {
|
||||
// min_count: <number> // optional, defaults to 10
|
||||
// }
|
||||
Json::Value RPCHandler::doGetCounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doGetCounts (RPC::Context& context)
|
||||
{
|
||||
int minCount = 10;
|
||||
|
||||
if (params.isMember ("min_count"))
|
||||
minCount = params["min_count"].asUInt ();
|
||||
if (context.params_.isMember ("min_count"))
|
||||
minCount = context.params_["min_count"].asUInt ();
|
||||
|
||||
CountedObjects::List objectCounts = CountedObjects::getInstance ().getCounts (minCount);
|
||||
|
||||
|
||||
95
src/ripple/module/rpc/handlers/Handlers.h
Normal file
95
src/ripple/module/rpc/handlers/Handlers.h
Normal file
@@ -0,0 +1,95 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_HANDLER_HANDLERS
|
||||
#define RIPPLE_HANDLER_HANDLERS
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value doAccountCurrencies (RPC::Context&);
|
||||
Json::Value doAccountInfo (RPC::Context&);
|
||||
Json::Value doAccountLines (RPC::Context&);
|
||||
Json::Value doAccountOffers (RPC::Context&);
|
||||
Json::Value doAccountTx (RPC::Context&);
|
||||
Json::Value doAccountTxSwitch (RPC::Context&);
|
||||
Json::Value doAccountTxOld (RPC::Context&);
|
||||
Json::Value doBookOffers (RPC::Context&);
|
||||
Json::Value doBlackList (RPC::Context&);
|
||||
Json::Value doConnect (RPC::Context&);
|
||||
Json::Value doConsensusInfo (RPC::Context&);
|
||||
Json::Value doFeature (RPC::Context&);
|
||||
Json::Value doFetchInfo (RPC::Context&);
|
||||
Json::Value doGetCounts (RPC::Context&);
|
||||
Json::Value doInternal (RPC::Context&);
|
||||
Json::Value doLedger (RPC::Context&);
|
||||
Json::Value doLedgerAccept (RPC::Context&);
|
||||
Json::Value doLedgerCleaner (RPC::Context&);
|
||||
Json::Value doLedgerClosed (RPC::Context&);
|
||||
Json::Value doLedgerCurrent (RPC::Context&);
|
||||
Json::Value doLedgerData (RPC::Context&);
|
||||
Json::Value doLedgerEntry (RPC::Context&);
|
||||
Json::Value doLedgerHeader (RPC::Context&);
|
||||
Json::Value doLedgerRequest (RPC::Context&);
|
||||
Json::Value doLogLevel (RPC::Context&);
|
||||
Json::Value doLogRotate (RPC::Context&);
|
||||
Json::Value doNicknameInfo (RPC::Context&);
|
||||
Json::Value doOwnerInfo (RPC::Context&);
|
||||
Json::Value doPathFind (RPC::Context&);
|
||||
Json::Value doPeers (RPC::Context&);
|
||||
Json::Value doPing (RPC::Context&);
|
||||
Json::Value doPrint (RPC::Context&);
|
||||
Json::Value doProfile (RPC::Context&);
|
||||
Json::Value doProofCreate (RPC::Context&);
|
||||
Json::Value doProofSolve (RPC::Context&);
|
||||
Json::Value doProofVerify (RPC::Context&);
|
||||
Json::Value doRandom (RPC::Context&);
|
||||
Json::Value doRipplePathFind (RPC::Context&);
|
||||
Json::Value doSMS (RPC::Context&);
|
||||
Json::Value doServerInfo (RPC::Context&); // for humans
|
||||
Json::Value doServerState (RPC::Context&); // for machines
|
||||
Json::Value doSessionClose (RPC::Context&);
|
||||
Json::Value doSessionOpen (RPC::Context&);
|
||||
Json::Value doSign (RPC::Context&);
|
||||
Json::Value doStop (RPC::Context&);
|
||||
Json::Value doSubmit (RPC::Context&);
|
||||
Json::Value doSubscribe (RPC::Context&);
|
||||
Json::Value doTransactionEntry (RPC::Context&);
|
||||
Json::Value doTx (RPC::Context&);
|
||||
Json::Value doTxHistory (RPC::Context&);
|
||||
Json::Value doUnlAdd (RPC::Context&);
|
||||
Json::Value doUnlDelete (RPC::Context&);
|
||||
Json::Value doUnlFetch (RPC::Context&);
|
||||
Json::Value doUnlList (RPC::Context&);
|
||||
Json::Value doUnlLoad (RPC::Context&);
|
||||
Json::Value doUnlNetwork (RPC::Context&);
|
||||
Json::Value doUnlReset (RPC::Context&);
|
||||
Json::Value doUnlScore (RPC::Context&);
|
||||
Json::Value doUnsubscribe (RPC::Context&);
|
||||
Json::Value doValidationCreate (RPC::Context&);
|
||||
Json::Value doValidationSeed (RPC::Context&);
|
||||
Json::Value doWalletAccounts (RPC::Context&);
|
||||
Json::Value doWalletLock (RPC::Context&);
|
||||
Json::Value doWalletPropose (RPC::Context&);
|
||||
Json::Value doWalletSeed (RPC::Context&);
|
||||
Json::Value doWalletUnlock (RPC::Context&);
|
||||
Json::Value doWalletVerify (RPC::Context&);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -25,10 +25,10 @@ namespace ripple {
|
||||
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
|
||||
// full: true | false // optional, defaults to false.
|
||||
// }
|
||||
Json::Value RPCHandler::doLedger (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedger (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
if (!params.isMember ("ledger") && !params.isMember ("ledger_hash") && !params.isMember ("ledger_index"))
|
||||
context.lock_.unlock ();
|
||||
if (!context.params_.isMember ("ledger") && !context.params_.isMember ("ledger_hash") && !context.params_.isMember ("ledger_index"))
|
||||
{
|
||||
Json::Value ret (Json::objectValue), current (Json::objectValue), closed (Json::objectValue);
|
||||
|
||||
@@ -42,15 +42,15 @@ Json::Value RPCHandler::doLedger (Json::Value params, Resource::Charge& loadType
|
||||
}
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
bool bFull = params.isMember ("full") && params["full"].asBool ();
|
||||
bool bTransactions = params.isMember ("transactions") && params["transactions"].asBool ();
|
||||
bool bAccounts = params.isMember ("accounts") && params["accounts"].asBool ();
|
||||
bool bExpand = params.isMember ("expand") && params["expand"].asBool ();
|
||||
bool bFull = context.params_.isMember ("full") && context.params_["full"].asBool ();
|
||||
bool bTransactions = context.params_.isMember ("transactions") && context.params_["transactions"].asBool ();
|
||||
bool bAccounts = context.params_.isMember ("accounts") && context.params_["accounts"].asBool ();
|
||||
bool bExpand = context.params_.isMember ("expand") && context.params_["expand"].asBool ();
|
||||
int iOptions = (bFull ? LEDGER_JSON_FULL : 0)
|
||||
| (bExpand ? LEDGER_JSON_EXPAND : 0)
|
||||
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
|
||||
@@ -59,19 +59,19 @@ Json::Value RPCHandler::doLedger (Json::Value params, Resource::Charge& loadType
|
||||
if (bFull || bAccounts)
|
||||
{
|
||||
|
||||
if (mRole != Config::ADMIN)
|
||||
if (context.role_ != Config::ADMIN)
|
||||
{
|
||||
// Until some sane way to get full ledgers has been implemented, disallow
|
||||
// retrieving all state nodes
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
}
|
||||
|
||||
if (getApp().getFeeTrack().isLoadedLocal() && (mRole != Config::ADMIN))
|
||||
if (getApp().getFeeTrack().isLoadedLocal() && (context.role_ != Config::ADMIN))
|
||||
{
|
||||
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
|
||||
return rpcError(rpcTOO_BUSY);
|
||||
}
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLedgerAccept (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerAccept (RPC::Context& context)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -30,9 +30,9 @@ Json::Value RPCHandler::doLedgerAccept (Json::Value, Resource::Charge& loadType,
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->acceptLedger ();
|
||||
context.netOps_.acceptLedger ();
|
||||
|
||||
jvResult["ledger_current_index"] = mNetOps->getCurrentLedgerID ();
|
||||
jvResult["ledger_current_index"] = context.netOps_.getCurrentLedgerID ();
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLedgerCleaner (Json::Value parameters, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerCleaner (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock();
|
||||
getApp().getLedgerMaster().doLedgerCleaner (parameters);
|
||||
context.lock_.unlock();
|
||||
getApp().getLedgerMaster().doLedgerCleaner (context.params_);
|
||||
return "Cleaner configured";
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLedgerClosed (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerClosed (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
Json::Value jvResult;
|
||||
|
||||
uint256 uLedger = mNetOps->getClosedLedgerHash ();
|
||||
uint256 uLedger = context.netOps_.getClosedLedgerHash ();
|
||||
|
||||
jvResult["ledger_index"] = mNetOps->getLedgerID (uLedger);
|
||||
jvResult["ledger_index"] = context.netOps_.getLedgerID (uLedger);
|
||||
jvResult["ledger_hash"] = to_string (uLedger);
|
||||
//jvResult["ledger_time"] = uLedger.
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLedgerCurrent (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerCurrent (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
Json::Value jvResult;
|
||||
|
||||
jvResult["ledger_current_index"] = mNetOps->getCurrentLedgerID ();
|
||||
jvResult["ledger_current_index"] = context.netOps_.getCurrentLedgerID ();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -30,23 +30,23 @@ namespace ripple {
|
||||
// ledger_index: chosen ledger's index
|
||||
// state: array of state nodes
|
||||
// marker: resume point, if any
|
||||
Json::Value RPCHandler::doLedgerData (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerData (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
int const BINARY_PAGE_LENGTH = 256;
|
||||
int const JSON_PAGE_LENGTH = 2048;
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
uint256 resumePoint;
|
||||
if (params.isMember ("marker"))
|
||||
if (context.params_.isMember ("marker"))
|
||||
{
|
||||
Json::Value const& jMarker = params["marker"];
|
||||
Json::Value const& jMarker = context.params_["marker"];
|
||||
if (!jMarker.isString ())
|
||||
return RPC::expected_field_error ("marker", "valid");
|
||||
if (!resumePoint.SetHex (jMarker.asString ()))
|
||||
@@ -54,9 +54,9 @@ Json::Value RPCHandler::doLedgerData (Json::Value params, Resource::Charge& load
|
||||
}
|
||||
|
||||
bool isBinary = false;
|
||||
if (params.isMember ("binary"))
|
||||
if (context.params_.isMember ("binary"))
|
||||
{
|
||||
Json::Value const& jBinary = params["binary"];
|
||||
Json::Value const& jBinary = context.params_["binary"];
|
||||
if (!jBinary.isBool ())
|
||||
return RPC::expected_field_error ("binary", "bool");
|
||||
isBinary = jBinary.asBool ();
|
||||
@@ -65,16 +65,16 @@ Json::Value RPCHandler::doLedgerData (Json::Value params, Resource::Charge& load
|
||||
int limit = -1;
|
||||
int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH;
|
||||
|
||||
if (params.isMember ("limit"))
|
||||
if (context.params_.isMember ("limit"))
|
||||
{
|
||||
Json::Value const& jLimit = params["limit"];
|
||||
Json::Value const& jLimit = context.params_["limit"];
|
||||
if (!jLimit.isIntegral ())
|
||||
return RPC::expected_field_error ("limit", "integer");
|
||||
|
||||
limit = jLimit.asInt ();
|
||||
}
|
||||
|
||||
if ((limit < 0) || ((limit > maxLimit) && (mRole != Config::ADMIN)))
|
||||
if ((limit < 0) || ((limit > maxLimit) && (context.role_ != Config::ADMIN)))
|
||||
limit = maxLimit;
|
||||
|
||||
Json::Value jvReply = Json::objectValue;
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace ripple {
|
||||
// ledger_index : <ledger_index>
|
||||
// ...
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerEntry (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
@@ -38,17 +38,17 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa
|
||||
uint256 uNodeIndex;
|
||||
bool bNodeBinary = false;
|
||||
|
||||
if (params.isMember ("index"))
|
||||
if (context.params_.isMember ("index"))
|
||||
{
|
||||
// XXX Needs to provide proof.
|
||||
uNodeIndex.SetHex (params["index"].asString ());
|
||||
uNodeIndex.SetHex (context.params_["index"].asString ());
|
||||
bNodeBinary = true;
|
||||
}
|
||||
else if (params.isMember ("account_root"))
|
||||
else if (context.params_.isMember ("account_root"))
|
||||
{
|
||||
RippleAddress naAccount;
|
||||
|
||||
if (!naAccount.setAccountID (params["account_root"].asString ())
|
||||
if (!naAccount.setAccountID (context.params_["account_root"].asString ())
|
||||
|| !naAccount.getAccountID ())
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
@@ -58,36 +58,36 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa
|
||||
uNodeIndex = Ledger::getAccountRootIndex (naAccount.getAccountID ());
|
||||
}
|
||||
}
|
||||
else if (params.isMember ("directory"))
|
||||
else if (context.params_.isMember ("directory"))
|
||||
{
|
||||
if (!params["directory"].isObject ())
|
||||
if (!context.params_["directory"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (params["directory"].asString ());
|
||||
uNodeIndex.SetHex (context.params_["directory"].asString ());
|
||||
}
|
||||
else if (params["directory"].isMember ("sub_index")
|
||||
&& !params["directory"]["sub_index"].isIntegral ())
|
||||
else if (context.params_["directory"].isMember ("sub_index")
|
||||
&& !context.params_["directory"]["sub_index"].isIntegral ())
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::uint64_t uSubIndex = params["directory"].isMember ("sub_index")
|
||||
? params["directory"]["sub_index"].asUInt ()
|
||||
std::uint64_t uSubIndex = context.params_["directory"].isMember ("sub_index")
|
||||
? context.params_["directory"]["sub_index"].asUInt ()
|
||||
: 0;
|
||||
|
||||
if (params["directory"].isMember ("dir_root"))
|
||||
if (context.params_["directory"].isMember ("dir_root"))
|
||||
{
|
||||
uint256 uDirRoot;
|
||||
|
||||
uDirRoot.SetHex (params["dir_root"].asString ());
|
||||
uDirRoot.SetHex (context.params_["dir_root"].asString ());
|
||||
|
||||
uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex);
|
||||
}
|
||||
else if (params["directory"].isMember ("owner"))
|
||||
else if (context.params_["directory"].isMember ("owner"))
|
||||
{
|
||||
RippleAddress naOwnerID;
|
||||
|
||||
if (!naOwnerID.setAccountID (params["directory"]["owner"].asString ()))
|
||||
if (!naOwnerID.setAccountID (context.params_["directory"]["owner"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
@@ -104,19 +104,19 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (params.isMember ("generator"))
|
||||
else if (context.params_.isMember ("generator"))
|
||||
{
|
||||
RippleAddress naGeneratorID;
|
||||
|
||||
if (!params["generator"].isObject ())
|
||||
if (!context.params_["generator"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (params["generator"].asString ());
|
||||
uNodeIndex.SetHex (context.params_["generator"].asString ());
|
||||
}
|
||||
else if (!params["generator"].isMember ("regular_seed"))
|
||||
else if (!context.params_["generator"].isMember ("regular_seed"))
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else if (!naGeneratorID.setSeedGeneric (params["generator"]["regular_seed"].asString ()))
|
||||
else if (!naGeneratorID.setSeedGeneric (context.params_["generator"]["regular_seed"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
@@ -130,37 +130,37 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa
|
||||
uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ());
|
||||
}
|
||||
}
|
||||
else if (params.isMember ("offer"))
|
||||
else if (context.params_.isMember ("offer"))
|
||||
{
|
||||
RippleAddress naAccountID;
|
||||
|
||||
if (!params["offer"].isObject ())
|
||||
if (!context.params_["offer"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (params["offer"].asString ());
|
||||
uNodeIndex.SetHex (context.params_["offer"].asString ());
|
||||
}
|
||||
else if (!params["offer"].isMember ("account")
|
||||
|| !params["offer"].isMember ("seq")
|
||||
|| !params["offer"]["seq"].isIntegral ())
|
||||
else if (!context.params_["offer"].isMember ("account")
|
||||
|| !context.params_["offer"].isMember ("seq")
|
||||
|| !context.params_["offer"]["seq"].isIntegral ())
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else if (!naAccountID.setAccountID (params["offer"]["account"].asString ()))
|
||||
else if (!naAccountID.setAccountID (context.params_["offer"]["account"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::uint32_t uSequence = params["offer"]["seq"].asUInt ();
|
||||
std::uint32_t uSequence = context.params_["offer"]["seq"].asUInt ();
|
||||
|
||||
uNodeIndex = Ledger::getOfferIndex (naAccountID.getAccountID (), uSequence);
|
||||
}
|
||||
}
|
||||
else if (params.isMember ("ripple_state"))
|
||||
else if (context.params_.isMember ("ripple_state"))
|
||||
{
|
||||
RippleAddress naA;
|
||||
RippleAddress naB;
|
||||
uint160 uCurrency;
|
||||
Json::Value jvRippleState = params["ripple_state"];
|
||||
Json::Value jvRippleState = context.params_["ripple_state"];
|
||||
|
||||
if (!jvRippleState.isObject ()
|
||||
|| !jvRippleState.isMember ("currency")
|
||||
@@ -195,10 +195,10 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa
|
||||
|
||||
if (uNodeIndex.isNonZero ())
|
||||
{
|
||||
SLE::pointer sleNode = mNetOps->getSLEi (lpLedger, uNodeIndex);
|
||||
SLE::pointer sleNode = context.netOps_.getSLEi (lpLedger, uNodeIndex);
|
||||
|
||||
if (params.isMember("binary"))
|
||||
bNodeBinary = params["binary"].asBool();
|
||||
if (context.params_.isMember("binary"))
|
||||
bNodeBinary = context.params_["binary"].asBool();
|
||||
|
||||
if (!sleNode)
|
||||
{
|
||||
|
||||
@@ -24,12 +24,12 @@ namespace ripple {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerHeader (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerHeader (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
@@ -24,15 +24,12 @@ namespace ripple {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doLedgerRequest (
|
||||
Json::Value params,
|
||||
Resource::Charge&,
|
||||
Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLedgerRequest (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
auto const hasHash = params.isMember (jss::ledger_hash);
|
||||
auto const hasIndex = params.isMember (jss::ledger_index);
|
||||
auto const hasHash = context.params_.isMember (jss::ledger_hash);
|
||||
auto const hasIndex = context.params_.isMember (jss::ledger_index);
|
||||
|
||||
auto& ledgerMaster = getApp().getLedgerMaster();
|
||||
LedgerHash ledgerHash;
|
||||
@@ -45,11 +42,11 @@ Json::Value RPCHandler::doLedgerRequest (
|
||||
|
||||
if (hasHash)
|
||||
{
|
||||
auto const& jsonHash = params[jss::ledger_hash];
|
||||
auto const& jsonHash = context.params_[jss::ledger_hash];
|
||||
if (!jsonHash.isString() || !ledgerHash.SetHex (jsonHash.asString ()))
|
||||
return RPC::invalid_field_message ("ledger_hash");
|
||||
} else {
|
||||
auto const& jsonIndex = params[jss::ledger_index];
|
||||
auto const& jsonIndex = context.params_[jss::ledger_index];
|
||||
if (!jsonIndex.isNumeric ())
|
||||
return RPC::invalid_field_message ("ledger_index");
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLogLevel (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLogLevel (RPC::Context& context)
|
||||
{
|
||||
// log_level
|
||||
if (!params.isMember ("severity"))
|
||||
if (!context.params_.isMember ("severity"))
|
||||
{
|
||||
// get log severities
|
||||
Json::Value ret (Json::objectValue);
|
||||
@@ -39,13 +39,13 @@ Json::Value RPCHandler::doLogLevel (Json::Value params, Resource::Charge& loadTy
|
||||
return ret;
|
||||
}
|
||||
|
||||
LogSeverity sv = Log::stringToSeverity (params["severity"].asString ());
|
||||
LogSeverity sv = Log::stringToSeverity (context.params_["severity"].asString ());
|
||||
|
||||
if (sv == lsINVALID)
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
// log_level severity
|
||||
if (!params.isMember ("partition"))
|
||||
if (!context.params_.isMember ("partition"))
|
||||
{
|
||||
// set base log severity
|
||||
LogSink::get()->setMinSeverity (sv, true);
|
||||
@@ -53,10 +53,10 @@ Json::Value RPCHandler::doLogLevel (Json::Value params, Resource::Charge& loadTy
|
||||
}
|
||||
|
||||
// log_level partition severity base?
|
||||
if (params.isMember ("partition"))
|
||||
if (context.params_.isMember ("partition"))
|
||||
{
|
||||
// set partition severity
|
||||
std::string partition (params["partition"].asString ());
|
||||
std::string partition (context.params_["partition"].asString ());
|
||||
|
||||
if (boost::iequals (partition, "base"))
|
||||
LogSink::get()->setMinSeverity (sv, false);
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doLogRotate (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doLogRotate (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
return LogSink::get()->rotateLog ();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace ripple {
|
||||
// XXX Needs to be revised for new paradigm
|
||||
// nickname_info <nickname>
|
||||
// Note: Nicknames are not automatically looked up by commands as they are advisory and can be changed.
|
||||
Json::Value RPCHandler::doNicknameInfo (Json::Value params)
|
||||
Json::Value doNicknameInfo (Json::Value params)
|
||||
{
|
||||
std::string strNickname = params[0u].asString ();
|
||||
std::string strNickname = context.params_[0u].asString ();
|
||||
boost::trim (strNickname);
|
||||
|
||||
if (strNickname.empty ())
|
||||
@@ -34,7 +34,7 @@ Json::Value RPCHandler::doNicknameInfo (Json::Value params)
|
||||
return rpcError (rpcNICKNAME_MALFORMED);
|
||||
}
|
||||
|
||||
NicknameState::pointer nsSrc = mNetOps->getNicknameState (uint256 (0), strNickname);
|
||||
NicknameState::pointer nsSrc = context.netOps_.getNicknameState (uint256 (0), strNickname);
|
||||
|
||||
if (!nsSrc)
|
||||
{
|
||||
|
||||
@@ -25,27 +25,27 @@ namespace ripple {
|
||||
// 'account_index' : <index> // optional
|
||||
// }
|
||||
// XXX This would be better if it took the ledger.
|
||||
Json::Value RPCHandler::doOwnerInfo (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doOwnerInfo (RPC::Context& context)
|
||||
{
|
||||
if (!params.isMember ("account") && !params.isMember ("ident"))
|
||||
if (!context.params_.isMember ("account") && !context.params_.isMember ("ident"))
|
||||
return RPC::missing_field_error ("account");
|
||||
|
||||
std::string strIdent = params.isMember ("account") ? params["account"].asString () : params["ident"].asString ();
|
||||
std::string strIdent = context.params_.isMember ("account") ? context.params_["account"].asString () : context.params_["ident"].asString ();
|
||||
bool bIndex;
|
||||
int iIndex = params.isMember ("account_index") ? params["account_index"].asUInt () : 0;
|
||||
int iIndex = context.params_.isMember ("account_index") ? context.params_["account_index"].asUInt () : 0;
|
||||
RippleAddress raAccount;
|
||||
|
||||
Json::Value ret;
|
||||
|
||||
// Get info on account.
|
||||
|
||||
Json::Value jAccepted = RPC::accountFromString (mNetOps->getClosedLedger (), raAccount, bIndex, strIdent, iIndex, false, *mNetOps);
|
||||
Json::Value jAccepted = RPC::accountFromString (context.netOps_.getClosedLedger (), raAccount, bIndex, strIdent, iIndex, false, context.netOps_);
|
||||
|
||||
ret["accepted"] = jAccepted.empty () ? mNetOps->getOwnerInfo (mNetOps->getClosedLedger (), raAccount) : jAccepted;
|
||||
ret["accepted"] = jAccepted.empty () ? context.netOps_.getOwnerInfo (context.netOps_.getClosedLedger (), raAccount) : jAccepted;
|
||||
|
||||
Json::Value jCurrent = RPC::accountFromString (mNetOps->getCurrentLedger (), raAccount, bIndex, strIdent, iIndex, false, *mNetOps);
|
||||
Json::Value jCurrent = RPC::accountFromString (context.netOps_.getCurrentLedger (), raAccount, bIndex, strIdent, iIndex, false, context.netOps_);
|
||||
|
||||
ret["current"] = jCurrent.empty () ? mNetOps->getOwnerInfo (mNetOps->getCurrentLedger (), raAccount) : jCurrent;
|
||||
ret["current"] = jCurrent.empty () ? context.netOps_.getOwnerInfo (context.netOps_.getCurrentLedger (), raAccount) : jCurrent;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,45 +20,45 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doPathFind (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doPathFind (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger = mNetOps->getClosedLedger();
|
||||
masterLockHolder.unlock();
|
||||
Ledger::pointer lpLedger = context.netOps_.getClosedLedger();
|
||||
context.lock_.unlock();
|
||||
|
||||
if (!params.isMember ("subcommand") || !params["subcommand"].isString ())
|
||||
if (!context.params_.isMember ("subcommand") || !context.params_["subcommand"].isString ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
if (!mInfoSub)
|
||||
if (!context.infoSub_)
|
||||
return rpcError (rpcNO_EVENTS);
|
||||
|
||||
std::string sSubCommand = params["subcommand"].asString ();
|
||||
std::string sSubCommand = context.params_["subcommand"].asString ();
|
||||
|
||||
if (sSubCommand == "create")
|
||||
{
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
mInfoSub->clearPathRequest ();
|
||||
return getApp().getPathRequests().makePathRequest (mInfoSub, lpLedger, params);
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.infoSub_->clearPathRequest ();
|
||||
return getApp().getPathRequests().makePathRequest (context.infoSub_, lpLedger, context.params_);
|
||||
}
|
||||
|
||||
if (sSubCommand == "close")
|
||||
{
|
||||
PathRequest::pointer request = mInfoSub->getPathRequest ();
|
||||
PathRequest::pointer request = context.infoSub_->getPathRequest ();
|
||||
|
||||
if (!request)
|
||||
return rpcError (rpcNO_PF_REQUEST);
|
||||
|
||||
mInfoSub->clearPathRequest ();
|
||||
return request->doClose (params);
|
||||
context.infoSub_->clearPathRequest ();
|
||||
return request->doClose (context.params_);
|
||||
}
|
||||
|
||||
if (sSubCommand == "status")
|
||||
{
|
||||
PathRequest::pointer request = mInfoSub->getPathRequest ();
|
||||
PathRequest::pointer request = context.infoSub_->getPathRequest ();
|
||||
|
||||
if (!request)
|
||||
return rpcError (rpcNO_PF_REQUEST);
|
||||
|
||||
return request->doStatus (params);
|
||||
return request->doStatus (context.params_);
|
||||
}
|
||||
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doPeers (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doPeers (RPC::Context& context)
|
||||
{
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doPing (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doPing (RPC::Context& context)
|
||||
{
|
||||
return Json::Value (Json::objectValue);
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doPrint (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doPrint (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
JsonPropertyStream stream;
|
||||
if (params.isObject() && params["params"].isArray() && params["params"][0u].isString ())
|
||||
getApp().write (stream, params["params"][0u].asString());
|
||||
if (context.params_.isObject() && context.params_["params"].isArray() && context.params_["params"][0u].isString ())
|
||||
getApp().write (stream, context.params_["params"][0u].asString());
|
||||
else
|
||||
getApp().write (stream);
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace ripple {
|
||||
// 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, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doProfile (RPC::Context& context)
|
||||
{
|
||||
/* need to fix now that sharedOfferCreate is gone
|
||||
int iArgs = params.size();
|
||||
int iArgs = context.params_.size();
|
||||
RippleAddress naSeedA;
|
||||
RippleAddress naAccountA;
|
||||
uint160 uCurrencyOfferA;
|
||||
@@ -38,26 +38,26 @@ Json::Value RPCHandler::doProfile (Json::Value params, Resource::Charge& loadTyp
|
||||
uint32 iCount = 100;
|
||||
bool bSubmit = false;
|
||||
|
||||
if (iArgs < 6 || "offers" != params[0u].asString())
|
||||
if (iArgs < 6 || "offers" != context.params_[0u].asString())
|
||||
{
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (!naSeedA.setSeedGeneric(params[1u].asString())) // <pass_a>
|
||||
if (!naSeedA.setSeedGeneric(context.params_[1u].asString())) // <pass_a>
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
naAccountA.setAccountID(params[2u].asString()); // <account_a>
|
||||
naAccountA.setAccountID(context.params_[2u].asString()); // <account_a>
|
||||
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferA, params[3u].asString())) // <currency_offer_a>
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferA, context.params_[3u].asString())) // <currency_offer_a>
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
naAccountB.setAccountID(params[4u].asString()); // <account_b>
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferB, params[5u].asString())) // <currency_offer_b>
|
||||
naAccountB.setAccountID(context.params_[4u].asString()); // <account_b>
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferB, context.params_[5u].asString())) // <currency_offer_b>
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
iCount = lexicalCast <uint32>(params[6u].asString());
|
||||
iCount = lexicalCast <uint32>(context.params_[6u].asString());
|
||||
|
||||
if (iArgs >= 8 && "false" != params[7u].asString())
|
||||
if (iArgs >= 8 && "false" != context.params_[7u].asString())
|
||||
bSubmit = true;
|
||||
|
||||
LogSink::get()->setMinSeverity(lsFATAL,true);
|
||||
@@ -90,7 +90,7 @@ Json::Value RPCHandler::doProfile (Json::Value params, Resource::Charge& loadTyp
|
||||
0); // uExpiration
|
||||
|
||||
if (bSubmit)
|
||||
tpOfferA = mNetOps->submitTransactionSync(tpOfferA); // FIXME: Don't use synch interface
|
||||
tpOfferA = context.netOps_.submitTransactionSync(tpOfferA); // FIXME: Don't use synch interface
|
||||
}
|
||||
|
||||
boost::posix_time::ptime ptEnd(boost::posix_time::microsec_clock::local_time());
|
||||
|
||||
@@ -26,24 +26,24 @@ namespace ripple {
|
||||
// difficulty: <number> // optional
|
||||
// secret: <secret> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doProofCreate (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doProofCreate (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
// XXX: Add ability to create proof with arbitrary time
|
||||
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
if (params.isMember ("difficulty") || params.isMember ("secret"))
|
||||
if (context.params_.isMember ("difficulty") || context.params_.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
std::unique_ptr <ProofOfWorkFactory> pgGen (ProofOfWorkFactory::New ());
|
||||
|
||||
if (params.isMember ("difficulty"))
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
{
|
||||
if (!params["difficulty"].isIntegral ())
|
||||
if (!context.params_["difficulty"].isIntegral ())
|
||||
return RPC::invalid_field_error ("difficulty");
|
||||
|
||||
int const iDifficulty (params["difficulty"].asInt ());
|
||||
int const iDifficulty (context.params_["difficulty"].asInt ());
|
||||
|
||||
if (iDifficulty < 0 || iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
|
||||
return RPC::invalid_field_error ("difficulty");
|
||||
@@ -51,9 +51,9 @@ Json::Value RPCHandler::doProofCreate (Json::Value params, Resource::Charge& loa
|
||||
pgGen->setDifficulty (iDifficulty);
|
||||
}
|
||||
|
||||
if (params.isMember ("secret"))
|
||||
if (context.params_.isMember ("secret"))
|
||||
{
|
||||
uint256 uSecret (params["secret"].asString ());
|
||||
uint256 uSecret (context.params_["secret"].asString ());
|
||||
pgGen->setSecret (uSecret);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,16 @@ namespace ripple {
|
||||
// {
|
||||
// token: <token>
|
||||
// }
|
||||
Json::Value RPCHandler::doProofSolve (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doProofSolve (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!params.isMember ("token"))
|
||||
if (!context.params_.isMember ("token"))
|
||||
return RPC::missing_field_error ("token");
|
||||
|
||||
std::string strToken = params["token"].asString ();
|
||||
std::string strToken = context.params_["token"].asString ();
|
||||
|
||||
if (!ProofOfWork::validateToken (strToken))
|
||||
return RPC::invalid_field_error ("token");
|
||||
|
||||
@@ -27,35 +27,35 @@ namespace ripple {
|
||||
// difficulty: <number> // optional
|
||||
// secret: <secret> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doProofVerify (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doProofVerify (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
// XXX Add ability to check proof against arbitrary time
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!params.isMember ("token"))
|
||||
if (!context.params_.isMember ("token"))
|
||||
return RPC::missing_field_error ("token");
|
||||
|
||||
if (!params.isMember ("solution"))
|
||||
if (!context.params_.isMember ("solution"))
|
||||
return RPC::missing_field_error ("solution");
|
||||
|
||||
std::string strToken = params["token"].asString ();
|
||||
uint256 uSolution (params["solution"].asString ());
|
||||
std::string strToken = context.params_["token"].asString ();
|
||||
uint256 uSolution (context.params_["solution"].asString ());
|
||||
|
||||
PowResult prResult;
|
||||
|
||||
if (params.isMember ("difficulty") || params.isMember ("secret"))
|
||||
if (context.params_.isMember ("difficulty") || context.params_.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
std::unique_ptr <ProofOfWorkFactory> pgGen (ProofOfWorkFactory::New ());
|
||||
|
||||
if (params.isMember ("difficulty"))
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
{
|
||||
if (!params["difficulty"].isIntegral ())
|
||||
if (!context.params_["difficulty"].isIntegral ())
|
||||
return RPC::invalid_field_error ("difficulty");
|
||||
|
||||
int iDifficulty = params["difficulty"].asInt ();
|
||||
int iDifficulty = context.params_["difficulty"].asInt ();
|
||||
|
||||
if (iDifficulty < 0 || iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
|
||||
return RPC::missing_field_error ("difficulty");
|
||||
@@ -63,9 +63,9 @@ Json::Value RPCHandler::doProofVerify (Json::Value params, Resource::Charge& loa
|
||||
pgGen->setDifficulty (iDifficulty);
|
||||
}
|
||||
|
||||
if (params.isMember ("secret"))
|
||||
if (context.params_.isMember ("secret"))
|
||||
{
|
||||
uint256 uSecret (params["secret"].asString ());
|
||||
uint256 uSecret (context.params_["secret"].asString ());
|
||||
pgGen->setSecret (uSecret);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace ripple {
|
||||
// {
|
||||
// random: <uint256>
|
||||
// }
|
||||
Json::Value RPCHandler::doRandom (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doRandom (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
uint256 uRandom;
|
||||
|
||||
try
|
||||
|
||||
@@ -22,17 +22,15 @@
|
||||
namespace ripple {
|
||||
|
||||
// This interface is deprecated.
|
||||
Json::Value RPCHandler::doRipplePathFind (
|
||||
Json::Value params, Resource::Charge& loadType,
|
||||
Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doRipplePathFind (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
RPC::LegacyPathFind lpf (mRole == Config::ADMIN);
|
||||
RPC::LegacyPathFind lpf (context.role_ == Config::ADMIN);
|
||||
if (!lpf.isOk ())
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
|
||||
RippleAddress raSrc;
|
||||
RippleAddress raDst;
|
||||
@@ -41,35 +39,35 @@ Json::Value RPCHandler::doRipplePathFind (
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
if (getConfig().RUN_STANDALONE || params.isMember("ledger") || params.isMember("ledger_index") || params.isMember("ledger_hash"))
|
||||
if (getConfig().RUN_STANDALONE || context.params_.isMember("ledger") || context.params_.isMember("ledger_index") || context.params_.isMember("ledger_hash"))
|
||||
{ // The caller specified a ledger
|
||||
jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if (!params.isMember ("source_account"))
|
||||
if (!context.params_.isMember ("source_account"))
|
||||
{
|
||||
jvResult = rpcError (rpcSRC_ACT_MISSING);
|
||||
}
|
||||
else if (!params["source_account"].isString ()
|
||||
|| !raSrc.setAccountID (params["source_account"].asString ()))
|
||||
else if (!context.params_["source_account"].isString ()
|
||||
|| !raSrc.setAccountID (context.params_["source_account"].asString ()))
|
||||
{
|
||||
jvResult = rpcError (rpcSRC_ACT_MALFORMED);
|
||||
}
|
||||
else if (!params.isMember ("destination_account"))
|
||||
else if (!context.params_.isMember ("destination_account"))
|
||||
{
|
||||
jvResult = rpcError (rpcDST_ACT_MISSING);
|
||||
}
|
||||
else if (!params["destination_account"].isString ()
|
||||
|| !raDst.setAccountID (params["destination_account"].asString ()))
|
||||
else if (!context.params_["destination_account"].isString ()
|
||||
|| !raDst.setAccountID (context.params_["destination_account"].asString ()))
|
||||
{
|
||||
jvResult = rpcError (rpcDST_ACT_MALFORMED);
|
||||
}
|
||||
else if (
|
||||
// Parse saDstAmount.
|
||||
!params.isMember ("destination_amount")
|
||||
|| !saDstAmount.bSetJson (params["destination_amount"])
|
||||
!context.params_.isMember ("destination_amount")
|
||||
|| !saDstAmount.bSetJson (context.params_["destination_amount"])
|
||||
|| saDstAmount <= zero
|
||||
|| (!!saDstAmount.getCurrency () && (!saDstAmount.getIssuer () || ACCOUNT_ONE == saDstAmount.getIssuer ())))
|
||||
{
|
||||
@@ -78,9 +76,9 @@ Json::Value RPCHandler::doRipplePathFind (
|
||||
}
|
||||
else if (
|
||||
// Checks on source_currencies.
|
||||
params.isMember ("source_currencies")
|
||||
&& (!params["source_currencies"].isArray ()
|
||||
|| !params["source_currencies"].size ()) // Don't allow empty currencies.
|
||||
context.params_.isMember ("source_currencies")
|
||||
&& (!context.params_["source_currencies"].isArray ()
|
||||
|| !context.params_["source_currencies"].size ()) // Don't allow empty currencies.
|
||||
)
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Bad source_currencies.";
|
||||
@@ -88,7 +86,7 @@ Json::Value RPCHandler::doRipplePathFind (
|
||||
}
|
||||
else
|
||||
{
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
RippleLineCache::pointer cache;
|
||||
|
||||
if (lpLedger)
|
||||
@@ -101,15 +99,15 @@ Json::Value RPCHandler::doRipplePathFind (
|
||||
{
|
||||
// The closed ledger is recent and any nodes made resident
|
||||
// have the best chance to persist
|
||||
lpLedger = mNetOps->getClosedLedger();
|
||||
lpLedger = context.netOps_.getClosedLedger();
|
||||
cache = getApp().getPathRequests().getLineCache(lpLedger, false);
|
||||
}
|
||||
|
||||
Json::Value jvSrcCurrencies;
|
||||
|
||||
if (params.isMember ("source_currencies"))
|
||||
if (context.params_.isMember ("source_currencies"))
|
||||
{
|
||||
jvSrcCurrencies = params["source_currencies"];
|
||||
jvSrcCurrencies = context.params_["source_currencies"];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -180,16 +178,16 @@ Json::Value RPCHandler::doRipplePathFind (
|
||||
int level = getConfig().PATH_SEARCH_OLD;
|
||||
if ((getConfig().PATH_SEARCH_MAX > level) && !getApp().getFeeTrack().isLoadedLocal())
|
||||
++level;
|
||||
if (params.isMember("depth") && params["depth"].isIntegral())
|
||||
if (context.params_.isMember("depth") && context.params_["depth"].isIntegral())
|
||||
{
|
||||
int rLev = params["search_depth"].asInt ();
|
||||
if ((rLev < level) || (mRole == Config::ADMIN))
|
||||
int rLev = context.params_["search_depth"].asInt ();
|
||||
if ((rLev < level) || (context.role_ == Config::ADMIN))
|
||||
level = rLev;
|
||||
}
|
||||
|
||||
if (params.isMember("paths"))
|
||||
if (context.params_.isMember("paths"))
|
||||
{
|
||||
STParsedJSON paths ("paths", params["paths"]);
|
||||
STParsedJSON paths ("paths", context.params_["paths"]);
|
||||
if (paths.object.get() == nullptr)
|
||||
return paths.error;
|
||||
else
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doSMS (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doSMS (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
if (!params.isMember ("text"))
|
||||
context.lock_.unlock ();
|
||||
if (!context.params_.isMember ("text"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
HTTPClient::sendSMS (getApp().getIOService (), params["text"].asString ());
|
||||
HTTPClient::sendSMS (getApp().getIOService (), context.params_["text"].asString ());
|
||||
|
||||
return "sms dispatched";
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doServerInfo (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doServerInfo (RPC::Context& context)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
ret["info"] = mNetOps->getServerInfo (true, mRole == Config::ADMIN);
|
||||
ret["info"] = context.netOps_.getServerInfo (true, context.role_ == Config::ADMIN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doServerState (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doServerState (RPC::Context& context)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
ret["state"] = mNetOps->getServerInfo (false, mRole == Config::ADMIN);
|
||||
ret["state"] = context.netOps_.getServerInfo (false, context.role_ == Config::ADMIN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace ripple {
|
||||
// tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value RPCHandler::doSign (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doSign (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (params, false, bFailHard, masterLockHolder, *mNetOps, mRole);
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
bool bFailHard = context.params_.isMember ("fail_hard") && context.params_["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (context.params_, false, bFailHard, context.lock_, context.netOps_, context.role_);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doStop (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doStop (RPC::Context& context)
|
||||
{
|
||||
getApp().signalStop ();
|
||||
|
||||
|
||||
@@ -24,21 +24,21 @@ namespace ripple {
|
||||
// tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doSubmit (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (!params.isMember ("tx_blob"))
|
||||
if (!context.params_.isMember ("tx_blob"))
|
||||
{
|
||||
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (params, true, bFailHard, masterLockHolder, *mNetOps, mRole);
|
||||
bool bFailHard = context.params_.isMember ("fail_hard") && context.params_["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (context.params_, true, bFailHard, context.lock_, context.netOps_, context.role_);
|
||||
}
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
std::pair<Blob, bool> ret(strUnHex (params["tx_blob"].asString ()));
|
||||
std::pair<Blob, bool> ret(strUnHex (context.params_["tx_blob"].asString ()));
|
||||
|
||||
if (!ret.second || !ret.first.size ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -76,8 +76,8 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
|
||||
try
|
||||
{
|
||||
(void) mNetOps->processTransaction (tpTrans, mRole == Config::ADMIN, true,
|
||||
params.isMember ("fail_hard") && params["fail_hard"].asBool ());
|
||||
(void) context.netOps_.processTransaction (tpTrans, context.role_ == Config::ADMIN, true,
|
||||
context.params_.isMember ("fail_hard") && context.params_["fail_hard"].asBool ());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doSubscribe (RPC::Context& context)
|
||||
{
|
||||
// FIXME: This needs to release the master lock immediately
|
||||
// Subscriptions need to be protected by their own lock
|
||||
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
std::uint32_t uLedgerIndex = params.isMember (jss::ledger_index) && params[jss::ledger_index].isNumeric ()
|
||||
? params[jss::ledger_index].asUInt ()
|
||||
std::uint32_t uLedgerIndex = context.params_.isMember (jss::ledger_index) && context.params_[jss::ledger_index].isNumeric ()
|
||||
? context.params_[jss::ledger_index].asUInt ()
|
||||
: 0;
|
||||
|
||||
if (!mInfoSub && !params.isMember ("url"))
|
||||
if (!context.infoSub_ && !context.params_.isMember ("url"))
|
||||
{
|
||||
// Must be a JSON-RPC call.
|
||||
WriteLog (lsINFO, RPCHandler) << boost::str (boost::format ("doSubscribe: RPC subscribe requires a url"));
|
||||
@@ -39,24 +39,24 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (params.isMember ("url"))
|
||||
if (context.params_.isMember ("url"))
|
||||
{
|
||||
if (mRole != Config::ADMIN)
|
||||
if (context.role_ != Config::ADMIN)
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
std::string strUrl = params["url"].asString ();
|
||||
std::string strUsername = params.isMember ("url_username") ? params["url_username"].asString () : "";
|
||||
std::string strPassword = params.isMember ("url_password") ? params["url_password"].asString () : "";
|
||||
std::string strUrl = context.params_["url"].asString ();
|
||||
std::string strUsername = context.params_.isMember ("url_username") ? context.params_["url_username"].asString () : "";
|
||||
std::string strPassword = context.params_.isMember ("url_password") ? context.params_["url_password"].asString () : "";
|
||||
|
||||
// DEPRECATED
|
||||
if (params.isMember ("username"))
|
||||
strUsername = params["username"].asString ();
|
||||
if (context.params_.isMember ("username"))
|
||||
strUsername = context.params_["username"].asString ();
|
||||
|
||||
// DEPRECATED
|
||||
if (params.isMember ("password"))
|
||||
strPassword = params["password"].asString ();
|
||||
if (context.params_.isMember ("password"))
|
||||
strPassword = context.params_["password"].asString ();
|
||||
|
||||
ispSub = mNetOps->findRpcSub (strUrl);
|
||||
ispSub = context.netOps_.findRpcSub (strUrl);
|
||||
|
||||
if (!ispSub)
|
||||
{
|
||||
@@ -65,28 +65,28 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
RPCSub::pointer rspSub = RPCSub::New (getApp ().getOPs (),
|
||||
getApp ().getIOService (), getApp ().getJobQueue (),
|
||||
strUrl, strUsername, strPassword);
|
||||
ispSub = mNetOps->addRpcSub (strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub));
|
||||
ispSub = context.netOps_.addRpcSub (strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub));
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsTRACE, RPCHandler) << boost::str (boost::format ("doSubscribe: reusing: %s") % strUrl);
|
||||
|
||||
if (params.isMember ("username"))
|
||||
if (context.params_.isMember ("username"))
|
||||
dynamic_cast<RPCSub*> (&*ispSub)->setUsername (strUsername);
|
||||
|
||||
if (params.isMember ("password"))
|
||||
if (context.params_.isMember ("password"))
|
||||
dynamic_cast<RPCSub*> (&*ispSub)->setPassword (strPassword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ispSub = mInfoSub;
|
||||
ispSub = context.infoSub_;
|
||||
}
|
||||
|
||||
if (!params.isMember ("streams"))
|
||||
if (!context.params_.isMember ("streams"))
|
||||
{
|
||||
}
|
||||
else if (!params["streams"].isArray ())
|
||||
else if (!context.params_["streams"].isArray ())
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << boost::str (boost::format ("doSubscribe: streams requires an array."));
|
||||
|
||||
@@ -94,7 +94,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Json::Value::iterator it = params["streams"].begin (); it != params["streams"].end (); it++)
|
||||
for (Json::Value::iterator it = context.params_["streams"].begin (); it != context.params_["streams"].end (); it++)
|
||||
{
|
||||
if ((*it).isString ())
|
||||
{
|
||||
@@ -102,20 +102,20 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
|
||||
if (streamName == "server")
|
||||
{
|
||||
mNetOps->subServer (ispSub, jvResult);
|
||||
context.netOps_.subServer (ispSub, jvResult);
|
||||
}
|
||||
else if (streamName == "ledger")
|
||||
{
|
||||
mNetOps->subLedger (ispSub, jvResult);
|
||||
context.netOps_.subLedger (ispSub, jvResult);
|
||||
}
|
||||
else if (streamName == "transactions")
|
||||
{
|
||||
mNetOps->subTransactions (ispSub);
|
||||
context.netOps_.subTransactions (ispSub);
|
||||
}
|
||||
else if (streamName == "transactions_proposed"
|
||||
|| streamName == "rt_transactions") // DEPRECATED
|
||||
{
|
||||
mNetOps->subRTTransactions (ispSub);
|
||||
context.netOps_.subRTTransactions (ispSub);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,20 +129,20 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
}
|
||||
|
||||
std::string strAccountsProposed = params.isMember ("accounts_proposed")
|
||||
std::string strAccountsProposed = context.params_.isMember ("accounts_proposed")
|
||||
? "accounts_proposed"
|
||||
: "rt_accounts"; // DEPRECATED
|
||||
|
||||
if (!params.isMember (strAccountsProposed))
|
||||
if (!context.params_.isMember (strAccountsProposed))
|
||||
{
|
||||
}
|
||||
else if (!params[strAccountsProposed].isArray ())
|
||||
else if (!context.params_[strAccountsProposed].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (params[strAccountsProposed]);
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_[strAccountsProposed]);
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
@@ -150,20 +150,20 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->subAccount (ispSub, usnaAccoundIds, uLedgerIndex, true);
|
||||
context.netOps_.subAccount (ispSub, usnaAccoundIds, uLedgerIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.isMember ("accounts"))
|
||||
if (!context.params_.isMember ("accounts"))
|
||||
{
|
||||
}
|
||||
else if (!params["accounts"].isArray ())
|
||||
else if (!context.params_["accounts"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (params["accounts"]);
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]);
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
@@ -171,23 +171,23 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->subAccount (ispSub, usnaAccoundIds, uLedgerIndex, false);
|
||||
context.netOps_.subAccount (ispSub, usnaAccoundIds, uLedgerIndex, false);
|
||||
|
||||
WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("doSubscribe: accounts: %d") % usnaAccoundIds.size ());
|
||||
}
|
||||
}
|
||||
|
||||
bool bHaveMasterLock = true;
|
||||
if (!params.isMember ("books"))
|
||||
if (!context.params_.isMember ("books"))
|
||||
{
|
||||
}
|
||||
else if (!params["books"].isArray ())
|
||||
else if (!context.params_["books"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Json::Value::iterator it = params["books"].begin (); it != params["books"].end (); it++)
|
||||
for (Json::Value::iterator it = context.params_["books"].begin (); it != context.params_["books"].end (); it++)
|
||||
{
|
||||
Json::Value& jvSubRequest = *it;
|
||||
|
||||
@@ -281,19 +281,19 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
return rpcError (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
mNetOps->subBook (ispSub, pay_currency, get_currency, pay_issuer, get_issuer);
|
||||
context.netOps_.subBook (ispSub, pay_currency, get_currency, pay_issuer, get_issuer);
|
||||
|
||||
if (bBoth) mNetOps->subBook (ispSub, get_currency, pay_currency, get_issuer, pay_issuer);
|
||||
if (bBoth) context.netOps_.subBook (ispSub, get_currency, pay_currency, get_issuer, pay_issuer);
|
||||
|
||||
if (bSnapshot)
|
||||
{
|
||||
if (bHaveMasterLock)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
bHaveMasterLock = false;
|
||||
}
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
Ledger::pointer lpLedger = getApp().getLedgerMaster ().getPublishedLedger ();
|
||||
if (lpLedger)
|
||||
{
|
||||
@@ -304,17 +304,17 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|
||||
Json::Value jvBids (Json::objectValue);
|
||||
Json::Value jvAsks (Json::objectValue);
|
||||
|
||||
mNetOps->getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvBids);
|
||||
context.netOps_.getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvBids);
|
||||
|
||||
if (jvBids.isMember (jss::offers)) jvResult[jss::bids] = jvBids[jss::offers];
|
||||
|
||||
mNetOps->getBookPage (lpLedger, get_currency, get_issuer, pay_currency, pay_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvAsks);
|
||||
context.netOps_.getBookPage (lpLedger, get_currency, get_issuer, pay_currency, pay_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvAsks);
|
||||
|
||||
if (jvAsks.isMember (jss::offers)) jvResult[jss::asks] = jvAsks[jss::offers];
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvResult);
|
||||
context.netOps_.getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, 0, jvMarker, jvResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,21 +25,21 @@ namespace ripple {
|
||||
// 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, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doTransactionEntry (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!params.isMember ("tx_hash"))
|
||||
if (!context.params_.isMember ("tx_hash"))
|
||||
{
|
||||
jvResult["error"] = "fieldNotFoundTransaction";
|
||||
}
|
||||
else if (!params.isMember ("ledger_hash") && !params.isMember ("ledger_index"))
|
||||
else if (!context.params_.isMember ("ledger_hash") && !context.params_.isMember ("ledger_index"))
|
||||
{
|
||||
// We don't work on ledger current.
|
||||
|
||||
@@ -49,7 +49,7 @@ Json::Value RPCHandler::doTransactionEntry (Json::Value params, Resource::Charge
|
||||
{
|
||||
uint256 uTransID;
|
||||
// XXX Relying on trusted WSS client. Would be better to have a strict routine, returning success or failure.
|
||||
uTransID.SetHex (params["tx_hash"].asString ());
|
||||
uTransID.SetHex (context.params_["tx_hash"].asString ());
|
||||
|
||||
if (!lpLedger)
|
||||
{
|
||||
|
||||
@@ -23,16 +23,16 @@ namespace ripple {
|
||||
// {
|
||||
// transaction: <hex>
|
||||
// }
|
||||
Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doTx (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
if (!params.isMember (jss::transaction))
|
||||
if (!context.params_.isMember (jss::transaction))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
bool binary = params.isMember (jss::binary) && params[jss::binary].asBool ();
|
||||
bool binary = context.params_.isMember (jss::binary) && context.params_[jss::binary].asBool ();
|
||||
|
||||
std::string strTransaction = params[jss::transaction].asString ();
|
||||
std::string strTransaction = context.params_[jss::transaction].asString ();
|
||||
|
||||
if (Transaction::isHexTxID (strTransaction))
|
||||
{
|
||||
@@ -53,7 +53,7 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
|
||||
if (txn->getLedger () != 0)
|
||||
{
|
||||
Ledger::pointer lgr = mNetOps->getLedgerBySeq (txn->getLedger ());
|
||||
Ledger::pointer lgr = context.netOps_.getLedgerBySeq (txn->getLedger ());
|
||||
|
||||
if (lgr)
|
||||
{
|
||||
@@ -81,7 +81,7 @@ Json::Value RPCHandler::doTx (Json::Value params, Resource::Charge& loadType, Ap
|
||||
}
|
||||
|
||||
if (okay)
|
||||
ret[jss::validated] = mNetOps->isValidated (lgr);
|
||||
ret[jss::validated] = context.netOps_.isValidated (lgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,17 +23,17 @@ namespace ripple {
|
||||
// {
|
||||
// start: <index>
|
||||
// }
|
||||
Json::Value RPCHandler::doTxHistory (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doTxHistory (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
context.lock_.unlock ();
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (!params.isMember ("start"))
|
||||
if (!context.params_.isMember ("start"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
unsigned int startIndex = params["start"].asUInt ();
|
||||
unsigned int startIndex = context.params_["start"].asUInt ();
|
||||
|
||||
if ((startIndex > 10000) && (mRole != Config::ADMIN))
|
||||
if ((startIndex > 10000) && (context.role_ != Config::ADMIN))
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
Json::Value obj;
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace ripple {
|
||||
// node: <domain>|<node_public>,
|
||||
// comment: <comment> // optional
|
||||
// }
|
||||
Json::Value RPCHandler::doUnlAdd (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlAdd (RPC::Context& context)
|
||||
{
|
||||
std::string strNode = params.isMember ("node") ? params["node"].asString () : "";
|
||||
std::string strComment = params.isMember ("comment") ? params["comment"].asString () : "";
|
||||
std::string strNode = context.params_.isMember ("node") ? context.params_["node"].asString () : "";
|
||||
std::string strComment = context.params_.isMember ("comment") ? context.params_["comment"].asString () : "";
|
||||
|
||||
RippleAddress raNodePublic;
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace ripple {
|
||||
// {
|
||||
// node: <domain>|<public_key>
|
||||
// }
|
||||
Json::Value RPCHandler::doUnlDelete (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlDelete (RPC::Context& context)
|
||||
{
|
||||
if (!params.isMember ("node"))
|
||||
if (!context.params_.isMember ("node"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
std::string strNode = params["node"].asString ();
|
||||
std::string strNode = context.params_["node"].asString ();
|
||||
|
||||
RippleAddress raNodePublic;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doUnlList (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlList (RPC::Context& context)
|
||||
{
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
namespace ripple {
|
||||
|
||||
// Populate the UNL from a local validators.txt file.
|
||||
Json::Value RPCHandler::doUnlLoad (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlLoad (RPC::Context& context)
|
||||
{
|
||||
if (getConfig ().VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (getConfig ().VALIDATORS_FILE))
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
namespace ripple {
|
||||
|
||||
// Populate the UNL from ripple.com's validators.txt file.
|
||||
Json::Value RPCHandler::doUnlNetwork (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlNetwork (RPC::Context& context)
|
||||
{
|
||||
getApp().getUNL ().nodeNetwork ();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Json::Value RPCHandler::doUnlReset (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlReset (RPC::Context& context)
|
||||
{
|
||||
getApp().getUNL ().nodeReset ();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
namespace ripple {
|
||||
|
||||
// unl_score
|
||||
Json::Value RPCHandler::doUnlScore (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnlScore (RPC::Context& context)
|
||||
{
|
||||
getApp().getUNL ().nodeScore ();
|
||||
|
||||
|
||||
@@ -21,37 +21,37 @@
|
||||
namespace ripple {
|
||||
|
||||
// FIXME: This leaks RPCSub objects for JSON-RPC. Shouldn't matter for anyone sane.
|
||||
Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doUnsubscribe (RPC::Context& context)
|
||||
{
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
if (!mInfoSub && !params.isMember ("url"))
|
||||
if (!context.infoSub_ && !context.params_.isMember ("url"))
|
||||
{
|
||||
// Must be a JSON-RPC call.
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (params.isMember ("url"))
|
||||
if (context.params_.isMember ("url"))
|
||||
{
|
||||
if (mRole != Config::ADMIN)
|
||||
if (context.role_ != Config::ADMIN)
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
std::string strUrl = params["url"].asString ();
|
||||
std::string strUrl = context.params_["url"].asString ();
|
||||
|
||||
ispSub = mNetOps->findRpcSub (strUrl);
|
||||
ispSub = context.netOps_.findRpcSub (strUrl);
|
||||
|
||||
if (!ispSub)
|
||||
return jvResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
ispSub = mInfoSub;
|
||||
ispSub = context.infoSub_;
|
||||
}
|
||||
|
||||
if (params.isMember ("streams"))
|
||||
if (context.params_.isMember ("streams"))
|
||||
{
|
||||
for (Json::Value::iterator it = params["streams"].begin (); it != params["streams"].end (); it++)
|
||||
for (Json::Value::iterator it = context.params_["streams"].begin (); it != context.params_["streams"].end (); it++)
|
||||
{
|
||||
if ((*it).isString ())
|
||||
{
|
||||
@@ -59,20 +59,20 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa
|
||||
|
||||
if (streamName == "server")
|
||||
{
|
||||
mNetOps->unsubServer (ispSub->getSeq ());
|
||||
context.netOps_.unsubServer (ispSub->getSeq ());
|
||||
}
|
||||
else if (streamName == "ledger")
|
||||
{
|
||||
mNetOps->unsubLedger (ispSub->getSeq ());
|
||||
context.netOps_.unsubLedger (ispSub->getSeq ());
|
||||
}
|
||||
else if (streamName == "transactions")
|
||||
{
|
||||
mNetOps->unsubTransactions (ispSub->getSeq ());
|
||||
context.netOps_.unsubTransactions (ispSub->getSeq ());
|
||||
}
|
||||
else if (streamName == "transactions_proposed"
|
||||
|| streamName == "rt_transactions") // DEPRECATED
|
||||
{
|
||||
mNetOps->unsubRTTransactions (ispSub->getSeq ());
|
||||
context.netOps_.unsubRTTransactions (ispSub->getSeq ());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -86,12 +86,12 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa
|
||||
}
|
||||
}
|
||||
|
||||
if (params.isMember ("accounts_proposed") || params.isMember ("rt_accounts"))
|
||||
if (context.params_.isMember ("accounts_proposed") || context.params_.isMember ("rt_accounts"))
|
||||
{
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (
|
||||
params.isMember ("accounts_proposed")
|
||||
? params["accounts_proposed"]
|
||||
: params["rt_accounts"]); // DEPRECATED
|
||||
context.params_.isMember ("accounts_proposed")
|
||||
? context.params_["accounts_proposed"]
|
||||
: context.params_["rt_accounts"]); // DEPRECATED
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
@@ -99,13 +99,13 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->unsubAccount (ispSub->getSeq (), usnaAccoundIds, true);
|
||||
context.netOps_.unsubAccount (ispSub->getSeq (), usnaAccoundIds, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.isMember ("accounts"))
|
||||
if (context.params_.isMember ("accounts"))
|
||||
{
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (params["accounts"]);
|
||||
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]);
|
||||
|
||||
if (usnaAccoundIds.empty ())
|
||||
{
|
||||
@@ -113,20 +113,20 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetOps->unsubAccount (ispSub->getSeq (), usnaAccoundIds, false);
|
||||
context.netOps_.unsubAccount (ispSub->getSeq (), usnaAccoundIds, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.isMember ("books"))
|
||||
if (!context.params_.isMember ("books"))
|
||||
{
|
||||
}
|
||||
else if (!params["books"].isArray ())
|
||||
else if (!context.params_["books"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Json::Value::iterator it = params["books"].begin (); it != params["books"].end (); it++)
|
||||
for (Json::Value::iterator it = context.params_["books"].begin (); it != context.params_["books"].end (); it++)
|
||||
{
|
||||
Json::Value& jvSubRequest = *it;
|
||||
|
||||
@@ -197,9 +197,9 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa
|
||||
return rpcError (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
mNetOps->unsubBook (ispSub->getSeq (), pay_currency, get_currency, pay_issuer, get_issuer);
|
||||
context.netOps_.unsubBook (ispSub->getSeq (), pay_currency, get_currency, pay_issuer, get_issuer);
|
||||
|
||||
if (bBoth) mNetOps->unsubBook (ispSub->getSeq (), get_currency, pay_currency, get_issuer, pay_issuer);
|
||||
if (bBoth) context.netOps_.unsubBook (ispSub->getSeq (), get_currency, pay_currency, get_issuer, pay_issuer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace ripple {
|
||||
// }
|
||||
//
|
||||
// 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, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doValidationCreate (RPC::Context& context)
|
||||
{
|
||||
RippleAddress raSeed;
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
if (!params.isMember ("secret"))
|
||||
if (!context.params_.isMember ("secret"))
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed.";
|
||||
|
||||
raSeed.setSeedRandom (); // Get a random seed.
|
||||
}
|
||||
else if (!raSeed.setSeedGeneric (params["secret"].asString ()))
|
||||
else if (!raSeed.setSeedGeneric (context.params_["secret"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace ripple {
|
||||
// {
|
||||
// secret: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doValidationSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doValidationSeed (RPC::Context& context)
|
||||
{
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
if (!params.isMember ("secret"))
|
||||
if (!context.params_.isMember ("secret"))
|
||||
{
|
||||
Log::out() << "Unset validation seed.";
|
||||
|
||||
@@ -35,7 +35,7 @@ Json::Value RPCHandler::doValidationSeed (Json::Value params, Resource::Charge&
|
||||
getConfig ().VALIDATION_PUB.clear ();
|
||||
getConfig ().VALIDATION_PRIV.clear ();
|
||||
}
|
||||
else if (!getConfig ().VALIDATION_SEED.setSeedGeneric (params["secret"].asString ()))
|
||||
else if (!getConfig ().VALIDATION_SEED.setSeedGeneric (context.params_["secret"].asString ()))
|
||||
{
|
||||
getConfig ().VALIDATION_PUB.clear ();
|
||||
getConfig ().VALIDATION_PRIV.clear ();
|
||||
|
||||
@@ -25,17 +25,17 @@ namespace ripple {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletAccounts (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doWalletAccounts (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (params, lpLedger, *mNetOps);
|
||||
Json::Value jvResult = RPC::lookupLedger (context.params_, lpLedger, context.netOps_);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
RippleAddress naSeed;
|
||||
|
||||
if (!params.isMember ("seed") || !naSeed.setSeedGeneric (params["seed"].asString ()))
|
||||
if (!context.params_.isMember ("seed") || !naSeed.setSeedGeneric (context.params_["seed"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
@@ -43,17 +43,17 @@ Json::Value RPCHandler::doWalletAccounts (Json::Value params, Resource::Charge&
|
||||
// Try the seed as a master seed.
|
||||
RippleAddress naMasterGenerator = RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
Json::Value jsonAccounts = RPC::accounts (lpLedger, naMasterGenerator, *mNetOps);
|
||||
Json::Value jsonAccounts = RPC::accounts (lpLedger, naMasterGenerator, context.netOps_);
|
||||
|
||||
if (jsonAccounts.empty ())
|
||||
{
|
||||
// No account via seed as master, try seed a regular.
|
||||
Json::Value ret = RPC::getMasterGenerator (lpLedger, naSeed, naMasterGenerator, *mNetOps);
|
||||
Json::Value ret = RPC::getMasterGenerator (lpLedger, naSeed, naMasterGenerator, context.netOps_);
|
||||
|
||||
if (!ret.empty ())
|
||||
return ret;
|
||||
|
||||
ret["accounts"] = RPC::accounts (lpLedger, naMasterGenerator, *mNetOps);
|
||||
ret["accounts"] = RPC::accounts (lpLedger, naMasterGenerator, context.netOps_);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ namespace ripple {
|
||||
// {
|
||||
// passphrase: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletPropose (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doWalletPropose (RPC::Context& context)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
context.lock_.unlock ();
|
||||
|
||||
RippleAddress naSeed;
|
||||
RippleAddress naAccount;
|
||||
|
||||
if (!params.isMember ("passphrase"))
|
||||
if (!context.params_.isMember ("passphrase"))
|
||||
naSeed.setSeedRandom ();
|
||||
|
||||
else if (!naSeed.setSeedGeneric (params["passphrase"].asString ()))
|
||||
else if (!naSeed.setSeedGeneric (context.params_["passphrase"].asString ()))
|
||||
return rpcError(rpcBAD_SEED);
|
||||
|
||||
RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace ripple {
|
||||
// {
|
||||
// secret: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doWalletSeed (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
Json::Value doWalletSeed (RPC::Context& context)
|
||||
{
|
||||
RippleAddress raSeed;
|
||||
bool bSecret = params.isMember ("secret");
|
||||
bool bSecret = context.params_.isMember ("secret");
|
||||
|
||||
if (bSecret && !raSeed.setSeedGeneric (params["secret"].asString ()))
|
||||
if (bSecret && !raSeed.setSeedGeneric (context.params_["secret"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
|
||||
41
src/ripple/module/rpc/impl/Context.h
Normal file
41
src/ripple/module/rpc/impl/Context.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_CONTEXT
|
||||
#define RIPPLE_RPC_CONTEXT
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
/** The context of information needed to call an RPC. */
|
||||
struct Context {
|
||||
Json::Value params_;
|
||||
Resource::Charge& loadType_;
|
||||
Application::ScopedLockType& lock_;
|
||||
NetworkOPs& netOps_;
|
||||
InfoSub::pointer infoSub_;
|
||||
Config::Role role_;
|
||||
};
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include <ripple/module/rpc/api/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/ErrorCodes.h>
|
||||
|
||||
namespace std {
|
||||
|
||||
|
||||
115
src/ripple/module/rpc/impl/Handler.cpp
Normal file
115
src/ripple/module/rpc/impl/Handler.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/module/rpc/impl/Handler.h>
|
||||
#include <ripple/module/rpc/handlers/Handlers.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace {
|
||||
|
||||
class HandlerTable {
|
||||
public:
|
||||
HandlerTable(std::vector<Handler> const& entries) {
|
||||
for (auto& entry: entries)
|
||||
table_[entry.name_] = entry;
|
||||
}
|
||||
|
||||
const Handler* getHandler(std::string name) {
|
||||
auto i = table_.find(name);
|
||||
return i == table_.end() ? nullptr : &i->second;
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<std::string, Handler> table_;
|
||||
};
|
||||
|
||||
HandlerTable HANDLERS({
|
||||
// Request-response methods
|
||||
{ "account_info", &doAccountInfo, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "account_currencies", &doAccountCurrencies, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "account_lines", &doAccountLines, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "account_offers", &doAccountOffers, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "account_tx", &doAccountTxSwitch, Config::USER, NEEDS_NETWORK_CONNECTION },
|
||||
{ "blacklist", &doBlackList, Config::ADMIN, NO_CONDITION },
|
||||
{ "book_offers", &doBookOffers, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "connect", &doConnect, Config::ADMIN, NO_CONDITION },
|
||||
{ "consensus_info", &doConsensusInfo, Config::ADMIN, NO_CONDITION },
|
||||
{ "get_counts", &doGetCounts, Config::ADMIN, NO_CONDITION },
|
||||
{ "internal", &doInternal, Config::ADMIN, NO_CONDITION },
|
||||
{ "feature", &doFeature, Config::ADMIN, NO_CONDITION },
|
||||
{ "fetch_info", &doFetchInfo, Config::ADMIN, NO_CONDITION },
|
||||
{ "ledger", &doLedger, Config::USER, NEEDS_NETWORK_CONNECTION },
|
||||
{ "ledger_accept", &doLedgerAccept, Config::ADMIN, NEEDS_CURRENT_LEDGER },
|
||||
{ "ledger_cleaner", &doLedgerCleaner, Config::ADMIN, NEEDS_NETWORK_CONNECTION },
|
||||
{ "ledger_closed", &doLedgerClosed, Config::USER, NEEDS_CLOSED_LEDGER },
|
||||
{ "ledger_current", &doLedgerCurrent, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "ledger_data", &doLedgerData, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "ledger_entry", &doLedgerEntry, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "ledger_header", &doLedgerHeader, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "ledger_request", &doLedgerRequest, Config::ADMIN, NO_CONDITION },
|
||||
{ "log_level", &doLogLevel, Config::ADMIN, NO_CONDITION },
|
||||
{ "logrotate", &doLogRotate, Config::ADMIN, NO_CONDITION },
|
||||
// { "nickname_info", &doNicknameInfo, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "owner_info", &doOwnerInfo, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "peers", &doPeers, Config::ADMIN, NO_CONDITION },
|
||||
{ "path_find", &doPathFind, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "ping", &doPing, Config::USER, NO_CONDITION },
|
||||
{ "print", &doPrint, Config::ADMIN, NO_CONDITION },
|
||||
// { "profile", &doProfile, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "proof_create", &doProofCreate, Config::ADMIN, NO_CONDITION },
|
||||
{ "proof_solve", &doProofSolve, Config::ADMIN, NO_CONDITION },
|
||||
{ "proof_verify", &doProofVerify, Config::ADMIN, NO_CONDITION },
|
||||
{ "random", &doRandom, Config::USER, NO_CONDITION },
|
||||
{ "ripple_path_find", &doRipplePathFind, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "sign", &doSign, Config::USER, NO_CONDITION },
|
||||
{ "submit", &doSubmit, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "server_info", &doServerInfo, Config::USER, NO_CONDITION },
|
||||
{ "server_state", &doServerState, Config::USER, NO_CONDITION },
|
||||
{ "sms", &doSMS, Config::ADMIN, NO_CONDITION },
|
||||
{ "stop", &doStop, Config::ADMIN, NO_CONDITION },
|
||||
{ "transaction_entry", &doTransactionEntry, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "tx", &doTx, Config::USER, NEEDS_NETWORK_CONNECTION },
|
||||
{ "tx_history", &doTxHistory, Config::USER, NO_CONDITION },
|
||||
{ "unl_add", &doUnlAdd, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_delete", &doUnlDelete, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_list", &doUnlList, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_load", &doUnlLoad, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_network", &doUnlNetwork, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_reset", &doUnlReset, Config::ADMIN, NO_CONDITION },
|
||||
{ "unl_score", &doUnlScore, Config::ADMIN, NO_CONDITION },
|
||||
{ "validation_create", &doValidationCreate, Config::ADMIN, NO_CONDITION },
|
||||
{ "validation_seed", &doValidationSeed, Config::ADMIN, NO_CONDITION },
|
||||
{ "wallet_accounts", &doWalletAccounts, Config::USER, NEEDS_CURRENT_LEDGER },
|
||||
{ "wallet_propose", &doWalletPropose, Config::ADMIN, NO_CONDITION },
|
||||
{ "wallet_seed", &doWalletSeed, Config::ADMIN, NO_CONDITION },
|
||||
|
||||
// Evented methods
|
||||
{ "subscribe", &doSubscribe, Config::USER, NO_CONDITION },
|
||||
{ "unsubscribe", &doUnsubscribe, Config::USER, NO_CONDITION },
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
const Handler* getHandler(std::string name) {
|
||||
return HANDLERS.getHandler(name);
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
51
src/ripple/module/rpc/impl/Handler.h
Normal file
51
src/ripple/module/rpc/impl/Handler.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_HANDLER
|
||||
#define RIPPLE_RPC_HANDLER
|
||||
|
||||
#include <ripple/module/rpc/RPCHandler.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
// Under what condition can we call this RPC?
|
||||
enum Condition {
|
||||
NO_CONDITION = 0,
|
||||
NEEDS_NETWORK_CONNECTION = 1,
|
||||
NEEDS_CURRENT_LEDGER = 2 + NEEDS_NETWORK_CONNECTION,
|
||||
NEEDS_CLOSED_LEDGER = 4 + NEEDS_NETWORK_CONNECTION,
|
||||
};
|
||||
|
||||
struct Handler
|
||||
{
|
||||
typedef Json::Value (*Method) (Context&);
|
||||
|
||||
const char* name_;
|
||||
Method method_;
|
||||
Config::Role role_;
|
||||
RPC::Condition condition_;
|
||||
};
|
||||
|
||||
const Handler* getHandler(std::string name);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/module/rpc/Tuning.h>
|
||||
#include <ripple/module/rpc/impl/LegacyPathFind.h>
|
||||
#include <ripple/module/rpc/api/Tuning.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#include <beast/cxx14/memory.h>
|
||||
|
||||
#include <ripple/module/rpc/api/Manager.h>
|
||||
|
||||
#include <ripple/module/rpc/Manager.h>
|
||||
#include <ripple/module/rpc/impl/DoPrint.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
228
src/ripple/module/rpc/impl/RPCHandler.cpp
Normal file
228
src/ripple/module/rpc/impl/RPCHandler.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/module/rpc/RPCHandler.h>
|
||||
#include <ripple/module/rpc/RPCServerHandler.h>
|
||||
#include <ripple/module/rpc/impl/Context.h>
|
||||
#include <ripple/module/rpc/impl/Handler.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
//
|
||||
// Carries out the RPC.
|
||||
//
|
||||
|
||||
SETUP_LOG (RPCHandler)
|
||||
|
||||
RPCHandler::RPCHandler (NetworkOPs& netOps)
|
||||
: mNetOps (&netOps)
|
||||
, mRole (Config::FORBID)
|
||||
{
|
||||
assert (mNetOps);
|
||||
}
|
||||
|
||||
RPCHandler::RPCHandler (NetworkOPs& netOps, InfoSub::pointer infoSub)
|
||||
: mNetOps (&netOps)
|
||||
, mInfoSub (infoSub)
|
||||
, mRole (Config::FORBID)
|
||||
{
|
||||
assert (mNetOps);
|
||||
}
|
||||
|
||||
// Provide the JSON-RPC "result" value.
|
||||
//
|
||||
// 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, Config::Role iRole,
|
||||
Resource::Charge& loadType)
|
||||
{
|
||||
WriteLog (lsTRACE, RPCHandler)
|
||||
<< "doRpcCommand:" << strMethod << ":" << jvParams;
|
||||
|
||||
if (!jvParams.isArray () || jvParams.size () > 1)
|
||||
return logRPCError (rpcError (rpcINVALID_PARAMS));
|
||||
|
||||
Json::Value params = jvParams.size () ? jvParams[0u]
|
||||
: Json::Value (Json::objectValue);
|
||||
|
||||
if (!params.isObject ())
|
||||
return logRPCError (rpcError (rpcINVALID_PARAMS));
|
||||
|
||||
// Provide the JSON-RPC method as the field "command" in the request.
|
||||
params[jss::command] = strMethod;
|
||||
|
||||
Json::Value jvResult = doCommand (params, iRole, loadType);
|
||||
|
||||
// Always report "status". On an error report the request as received.
|
||||
if (jvResult.isMember ("error"))
|
||||
{
|
||||
jvResult[jss::status] = jss::error;
|
||||
jvResult[jss::request] = params;
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult[jss::status] = jss::success;
|
||||
}
|
||||
|
||||
return logRPCError (jvResult);
|
||||
}
|
||||
|
||||
// TODO(tom): this should go with the other handlers.
|
||||
Json::Value doInternal (RPC::Context& context)
|
||||
{
|
||||
// Used for debug or special-purpose RPC commands
|
||||
if (!context.params_.isMember ("internal_command"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
return RPCInternalHandler::runHandler (
|
||||
context.params_["internal_command"].asString (),
|
||||
context.params_["params"]);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doCommand (
|
||||
const Json::Value& params, Config::Role iRole, Resource::Charge& loadType)
|
||||
{
|
||||
if (iRole != Config::ADMIN)
|
||||
{
|
||||
// VFALCO NOTE Should we also add up the jtRPC jobs?
|
||||
//
|
||||
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
|
||||
if (jc > 500)
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "Too busy for command: " << jc;
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.isMember ("command"))
|
||||
return rpcError (rpcCOMMAND_MISSING);
|
||||
|
||||
std::string strCommand = params[jss::command].asString ();
|
||||
|
||||
WriteLog (lsTRACE, RPCHandler) << "COMMAND:" << strCommand;
|
||||
WriteLog (lsTRACE, RPCHandler) << "REQUEST:" << params;
|
||||
|
||||
mRole = iRole;
|
||||
|
||||
const RPC::Handler* handler = RPC::getHandler(strCommand);
|
||||
|
||||
if (!handler)
|
||||
return rpcError (rpcUNKNOWN_COMMAND);
|
||||
|
||||
if (handler->role_ == Config::ADMIN && mRole != Config::ADMIN)
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
Application::ScopedLockType lock (getApp().getMasterLock ());
|
||||
|
||||
if ((handler->condition_ & RPC::NEEDS_NETWORK_CONNECTION) &&
|
||||
(mNetOps->getOperatingMode () < NetworkOPs::omSYNCING))
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler)
|
||||
<< "Insufficient network mode for RPC: "
|
||||
<< mNetOps->strOperatingMode ();
|
||||
|
||||
return rpcError (rpcNO_NETWORK);
|
||||
}
|
||||
|
||||
if (!getConfig ().RUN_STANDALONE
|
||||
&& (handler->condition_ & RPC::NEEDS_CURRENT_LEDGER)
|
||||
&& (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
|
||||
{
|
||||
return rpcError (rpcNO_CURRENT);
|
||||
}
|
||||
|
||||
if ((handler->condition_ & RPC::NEEDS_CLOSED_LEDGER) &&
|
||||
!mNetOps->getClosedLedger ())
|
||||
{
|
||||
return rpcError (rpcNO_CLOSED);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LoadEvent::autoptr ev = getApp().getJobQueue().getLoadEventAP(
|
||||
jtGENERIC, std::string("cmd:") + strCommand);
|
||||
RPC::Context context{params, loadType, lock, *mNetOps, mInfoSub, mRole};
|
||||
Json::Value jvRaw = handler->method_(context);
|
||||
|
||||
// Regularize result.
|
||||
if (jvRaw.isObject ())
|
||||
{
|
||||
// Got an object.
|
||||
return jvRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably got a string.
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
jvResult[jss::message] = jvRaw;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what ();
|
||||
|
||||
if (loadType == Resource::feeReferenceRPC)
|
||||
loadType = Resource::feeExceptionRPC;
|
||||
|
||||
return rpcError (rpcINTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
RPCInternalHandler* RPCInternalHandler::sHeadHandler = nullptr;
|
||||
|
||||
RPCInternalHandler::RPCInternalHandler (
|
||||
const std::string& name, handler_t Handler)
|
||||
: mName (name),
|
||||
mHandler (Handler)
|
||||
{
|
||||
mNextHandler = sHeadHandler;
|
||||
sHeadHandler = this;
|
||||
}
|
||||
|
||||
Json::Value RPCInternalHandler::runHandler (
|
||||
const std::string& name, const Json::Value& params)
|
||||
{
|
||||
RPCInternalHandler* h = sHeadHandler;
|
||||
while (h != nullptr)
|
||||
{
|
||||
if (name == h->mName)
|
||||
{
|
||||
WriteLog (lsWARNING, RPCHandler)
|
||||
<< "Internal command " << name << ": " << params;
|
||||
Json::Value ret = h->mHandler (params);
|
||||
WriteLog (lsWARNING, RPCHandler)
|
||||
<< "Internal command returns: " << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
h = h->mNextHandler;
|
||||
}
|
||||
|
||||
return rpcError (rpcBAD_SYNTAX);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/module/app/rpc/RPCHandler.h>
|
||||
#include <ripple/module/app/rpc/RPCServerHandler.h>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/module/rpc/RPCHandler.h>
|
||||
#include <ripple/module/rpc/RPCServerHandler.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -57,7 +57,7 @@ std::string RPCServerHandler::processRequest (std::string const& request,
|
||||
return createResponse (400, "Unable to parse request");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Config::Role const role (getConfig ().getAdminRole (jsonRequest, remoteIPAddress));
|
||||
|
||||
Resource::Consumer usage;
|
||||
@@ -117,7 +117,7 @@ std::string RPCServerHandler::processRequest (std::string const& request,
|
||||
}
|
||||
|
||||
std::string response;
|
||||
|
||||
|
||||
WriteLog (lsDEBUG, RPCServer) << "Query: " << strMethod << params;
|
||||
|
||||
{
|
||||
@@ -142,7 +142,7 @@ std::string RPCServerHandler::processRequest (std::string const& request,
|
||||
|
||||
// legacy dispatcher
|
||||
Resource::Charge fee (Resource::feeReferenceRPC);
|
||||
RPCHandler rpcHandler (&m_networkOPs);
|
||||
RPCHandler rpcHandler (m_networkOPs);
|
||||
Json::Value const result = rpcHandler.doRpcCommand (
|
||||
strMethod, params, role, fee);
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <ripple/module/app/main/IoServicePool.cpp>
|
||||
#include <ripple/module/app/main/FatalErrorReporter.cpp>
|
||||
#include <ripple/module/app/main/RPCHTTPServer.cpp>
|
||||
#include <ripple/module/app/rpc/RPCServerHandler.cpp>
|
||||
#include <ripple/module/app/rpc/RPCHandler.cpp>
|
||||
#include <ripple/module/app/tx/TxQueueEntry.h>
|
||||
#include <ripple/module/app/tx/TxQueueEntry.cpp>
|
||||
#include <ripple/module/app/tx/TxQueue.cpp>
|
||||
@@ -79,7 +77,7 @@ int main (int argc, char** argv)
|
||||
|
||||
static_assert (BOOST_VERSION >= 105500,
|
||||
"Boost version 1.55 or later is required to compile rippled");
|
||||
|
||||
|
||||
//
|
||||
// These debug heap calls do nothing in release or non Visual Studio builds.
|
||||
//
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#pragma warning (disable: 4309) // truncation of constant value
|
||||
#endif
|
||||
|
||||
#include <ripple/module/rpc/api/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/ErrorCodes.h>
|
||||
|
||||
#include <ripple/module/app/paths/PathRequest.cpp>
|
||||
#include <ripple/module/app/paths/PathRequests.cpp>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include <ripple/unity/sslutil.h>
|
||||
#include <ripple/module/rpc/api/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/ErrorCodes.h>
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
|
||||
// VFALCO TODO fix these warnings!
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
// directly (instead of the module header). The corresponding .cpp
|
||||
// still uses the unity style inclusion.
|
||||
//
|
||||
#include <ripple/module/rpc/api/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/ErrorCodes.h>
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
|
||||
#include <ripple/module/net/basics/HTTPRequest.cpp>
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <BeastConfig.h>
|
||||
|
||||
// Unfortunate but necessary since RPC handlers can literally do anything
|
||||
@@ -26,13 +28,15 @@
|
||||
|
||||
#include <ripple/unity/rpcx.h>
|
||||
|
||||
#include <ripple/module/app/rpc/RPCHandler.h>
|
||||
#include <ripple/module/overlay/api/Overlay.h>
|
||||
#include <tuple>
|
||||
|
||||
#include <ripple/module/rpc/RPCHandler.h>
|
||||
#include <ripple/module/rpc/impl/ErrorCodes.cpp>
|
||||
#include <ripple/module/rpc/impl/Manager.cpp>
|
||||
#include <ripple/module/rpc/impl/RPCServerHandler.cpp>
|
||||
#include <ripple/module/rpc/impl/RPCHandler.cpp>
|
||||
|
||||
#include <ripple/module/rpc/handlers/Handlers.h>
|
||||
#include <ripple/module/rpc/handlers/AccountCurrencies.cpp>
|
||||
#include <ripple/module/rpc/handlers/AccountInfo.cpp>
|
||||
#include <ripple/module/rpc/handlers/AccountLines.cpp>
|
||||
@@ -98,6 +102,7 @@
|
||||
#include <ripple/module/rpc/impl/Accounts.cpp>
|
||||
#include <ripple/module/rpc/impl/Authorize.cpp>
|
||||
#include <ripple/module/rpc/impl/GetMasterGenerator.cpp>
|
||||
#include <ripple/module/rpc/impl/Handler.cpp>
|
||||
#include <ripple/module/rpc/impl/LegacyPathFind.cpp>
|
||||
#include <ripple/module/rpc/impl/LookupLedger.cpp>
|
||||
#include <ripple/module/rpc/impl/ParseAccountIds.cpp>
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef RIPPLE_RPC_H_INCLUDED
|
||||
#define RIPPLE_RPC_H_INCLUDED
|
||||
|
||||
#include <ripple/module/rpc/api/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/api/Manager.h>
|
||||
#include <ripple/module/rpc/api/Request.h>
|
||||
#include <ripple/module/rpc/ErrorCodes.h>
|
||||
#include <ripple/module/rpc/Manager.h>
|
||||
#include <ripple/module/rpc/Request.h>
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user