mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 17:35:51 +00:00
Refactor RPC tx_history.
This commit is contained in:
@@ -266,6 +266,16 @@ Json::Value RPCParser::parseTx(const Json::Value& jvParams)
|
|||||||
return jvRequest;
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tx_history <index>
|
||||||
|
Json::Value RPCParser::parseTxHistory(const Json::Value& jvParams)
|
||||||
|
{
|
||||||
|
Json::Value jvRequest;
|
||||||
|
|
||||||
|
jvRequest["start"] = jvParams[0u].asUInt();
|
||||||
|
|
||||||
|
return jvRequest;
|
||||||
|
}
|
||||||
|
|
||||||
// unl_add <domain>|<node_public> [<comment>]
|
// unl_add <domain>|<node_public> [<comment>]
|
||||||
Json::Value RPCParser::parseUnlAdd(const Json::Value& jvParams)
|
Json::Value RPCParser::parseUnlAdd(const Json::Value& jvParams)
|
||||||
{
|
{
|
||||||
@@ -404,8 +414,8 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
||||||
// { "transaction_entry", &RPCParser::parseTransactionEntry, -1, -1 },
|
// { "transaction_entry", &RPCParser::parseTransactionEntry, -1, -1 },
|
||||||
{ "tx", &RPCParser::parseTx, 1, 1 },
|
{ "tx", &RPCParser::parseTx, 1, 1 },
|
||||||
// { "tx_history", &RPCParser::parseTxHistory, 1, 1 },
|
{ "tx_history", &RPCParser::parseTxHistory, 1, 1 },
|
||||||
//
|
|
||||||
{ "unl_add", &RPCParser::parseUnlAdd, 1, 2 },
|
{ "unl_add", &RPCParser::parseUnlAdd, 1, 2 },
|
||||||
{ "unl_delete", &RPCParser::parseUnlDelete, 1, 1 },
|
{ "unl_delete", &RPCParser::parseUnlDelete, 1, 1 },
|
||||||
{ "unl_list", &RPCParser::parseAsIs, 0, 0 },
|
{ "unl_list", &RPCParser::parseAsIs, 0, 0 },
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ protected:
|
|||||||
Json::Value parseRippleLinesGet(const Json::Value& jvParams);
|
Json::Value parseRippleLinesGet(const Json::Value& jvParams);
|
||||||
Json::Value parseSubmit(const Json::Value& jvParams);
|
Json::Value parseSubmit(const Json::Value& jvParams);
|
||||||
Json::Value parseTx(const Json::Value& jvParams);
|
Json::Value parseTx(const Json::Value& jvParams);
|
||||||
|
Json::Value parseTxHistory(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
||||||
Json::Value parseValidationCreate(const Json::Value& jvParams);
|
Json::Value parseValidationCreate(const Json::Value& jvParams);
|
||||||
|
|||||||
@@ -329,13 +329,13 @@ Json::Value RPCHandler::doAccountInfo(Json::Value jvRequest)
|
|||||||
// port: <number>
|
// port: <number>
|
||||||
// }
|
// }
|
||||||
// XXX Might allow domain for manual connections.
|
// XXX Might allow domain for manual connections.
|
||||||
Json::Value RPCHandler::doConnect(Json::Value jvParams)
|
Json::Value RPCHandler::doConnect(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
if (theConfig.RUN_STANDALONE)
|
if (theConfig.RUN_STANDALONE)
|
||||||
return "cannot connect in standalone mode";
|
return "cannot connect in standalone mode";
|
||||||
|
|
||||||
std::string strIp = jvParams["ip"].asString();
|
std::string strIp = jvRequest["ip"].asString();
|
||||||
int iPort = jvParams.isMember("port") ? jvParams["port"].asInt() : -1;
|
int iPort = jvRequest.isMember("port") ? jvRequest["port"].asInt() : -1;
|
||||||
|
|
||||||
// XXX Validate legal IP and port
|
// XXX Validate legal IP and port
|
||||||
theApp->getConnectionPool().connectTo(strIp, iPort);
|
theApp->getConnectionPool().connectTo(strIp, iPort);
|
||||||
@@ -1069,37 +1069,35 @@ Json::Value RPCHandler::doServerInfo(Json::Value)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value RPCHandler::doTxHistory(Json::Value params)
|
// {
|
||||||
|
// start: <index>
|
||||||
|
// }
|
||||||
|
Json::Value RPCHandler::doTxHistory(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
if (params.size() == 1)
|
unsigned int startIndex = jvRequest["start"].asUInt();
|
||||||
|
Json::Value obj;
|
||||||
|
Json::Value txs;
|
||||||
|
|
||||||
|
obj["index"]=startIndex;
|
||||||
|
|
||||||
|
std::string sql =
|
||||||
|
boost::str(boost::format("SELECT * FROM Transactions ORDER BY LedgerSeq desc LIMIT %u,20")
|
||||||
|
% startIndex);
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int startIndex = params[0u].asInt();
|
Database* db = theApp->getTxnDB()->getDB();
|
||||||
Json::Value obj;
|
ScopedLock sl (theApp->getTxnDB()->getDBLock());
|
||||||
Json::Value txs;
|
|
||||||
|
|
||||||
obj["index"]=startIndex;
|
|
||||||
|
|
||||||
std::string sql =
|
|
||||||
boost::str(boost::format("SELECT * FROM Transactions ORDER BY LedgerSeq desc LIMIT %u,20")
|
|
||||||
% startIndex);
|
|
||||||
|
|
||||||
|
SQL_FOREACH(db, sql)
|
||||||
{
|
{
|
||||||
Database* db = theApp->getTxnDB()->getDB();
|
Transaction::pointer trans=Transaction::transactionFromSQL(db, false);
|
||||||
ScopedLock sl (theApp->getTxnDB()->getDBLock());
|
if(trans) txs.append(trans->getJson(0));
|
||||||
|
|
||||||
SQL_FOREACH(db, sql)
|
|
||||||
{
|
|
||||||
Transaction::pointer trans=Transaction::transactionFromSQL(db, false);
|
|
||||||
if(trans) txs.append(trans->getJson(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj["txs"]=txs;
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcError(rpcSRC_ACT_MALFORMED);
|
obj["txs"]=txs;
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// {
|
// {
|
||||||
@@ -1147,9 +1145,9 @@ Json::Value RPCHandler::doLedgerCurrent(Json::Value)
|
|||||||
// ledger: 'ledger_current' | 'ledger_closed' | <hex> | <number>, // optional
|
// ledger: 'ledger_current' | 'ledger_closed' | <hex> | <number>, // optional
|
||||||
// full: true | false // optional, defaults to false.
|
// full: true | false // optional, defaults to false.
|
||||||
// }
|
// }
|
||||||
Json::Value RPCHandler::doLedger(Json::Value jvParams)
|
Json::Value RPCHandler::doLedger(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
if (!jvParams.isMember("ledger"))
|
if (!jvRequest.isMember("ledger"))
|
||||||
{
|
{
|
||||||
Json::Value ret(Json::objectValue), current(Json::objectValue), closed(Json::objectValue);
|
Json::Value ret(Json::objectValue), current(Json::objectValue), closed(Json::objectValue);
|
||||||
|
|
||||||
@@ -1162,7 +1160,7 @@ Json::Value RPCHandler::doLedger(Json::Value jvParams)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strLedger = jvParams["ledger"].asString();
|
std::string strLedger = jvRequest["ledger"].asString();
|
||||||
Ledger::pointer ledger;
|
Ledger::pointer ledger;
|
||||||
|
|
||||||
if (strLedger == "ledger_current")
|
if (strLedger == "ledger_current")
|
||||||
@@ -1172,12 +1170,12 @@ Json::Value RPCHandler::doLedger(Json::Value jvParams)
|
|||||||
else if (strLedger.size() > 12)
|
else if (strLedger.size() > 12)
|
||||||
ledger = theApp->getLedgerMaster().getLedgerByHash(uint256(strLedger));
|
ledger = theApp->getLedgerMaster().getLedgerByHash(uint256(strLedger));
|
||||||
else
|
else
|
||||||
ledger = theApp->getLedgerMaster().getLedgerBySeq(jvParams["ledger"].asUInt());
|
ledger = theApp->getLedgerMaster().getLedgerBySeq(jvRequest["ledger"].asUInt());
|
||||||
|
|
||||||
if (!ledger)
|
if (!ledger)
|
||||||
return rpcError(rpcLGR_NOT_FOUND);
|
return rpcError(rpcLGR_NOT_FOUND);
|
||||||
|
|
||||||
bool full = jvParams.isMember("full") && jvParams["full"].asBool();
|
bool full = jvRequest.isMember("full") && jvRequest["full"].asBool();
|
||||||
|
|
||||||
Json::Value ret(Json::objectValue);
|
Json::Value ret(Json::objectValue);
|
||||||
|
|
||||||
@@ -1249,17 +1247,17 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest)
|
|||||||
// {
|
// {
|
||||||
// secret: <string>
|
// secret: <string>
|
||||||
// }
|
// }
|
||||||
Json::Value RPCHandler::doValidationCreate(Json::Value jvParams) {
|
Json::Value RPCHandler::doValidationCreate(Json::Value jvRequest) {
|
||||||
RippleAddress raSeed;
|
RippleAddress raSeed;
|
||||||
Json::Value obj(Json::objectValue);
|
Json::Value obj(Json::objectValue);
|
||||||
|
|
||||||
if (!jvParams.isMember("secret"))
|
if (!jvRequest.isMember("secret"))
|
||||||
{
|
{
|
||||||
cLog(lsDEBUG) << "Creating random validation seed.";
|
cLog(lsDEBUG) << "Creating random validation seed.";
|
||||||
|
|
||||||
raSeed.setSeedRandom(); // Get a random seed.
|
raSeed.setSeedRandom(); // Get a random seed.
|
||||||
}
|
}
|
||||||
else if (!raSeed.setSeedGeneric(jvParams["secret"].asString()))
|
else if (!raSeed.setSeedGeneric(jvRequest["secret"].asString()))
|
||||||
{
|
{
|
||||||
return rpcError(rpcBAD_SEED);
|
return rpcError(rpcBAD_SEED);
|
||||||
}
|
}
|
||||||
@@ -1339,11 +1337,11 @@ Json::Value RPCHandler::accounts(const uint256& uLedger, const RippleAddress& na
|
|||||||
// {
|
// {
|
||||||
// seed: <string>
|
// seed: <string>
|
||||||
// }
|
// }
|
||||||
Json::Value RPCHandler::doWalletAccounts(Json::Value jvParams)
|
Json::Value RPCHandler::doWalletAccounts(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
RippleAddress naSeed;
|
RippleAddress naSeed;
|
||||||
|
|
||||||
if (!jvParams.isMember("seed") || !naSeed.setSeedGeneric(jvParams["seed"].asString()))
|
if (!jvRequest.isMember("seed") || !naSeed.setSeedGeneric(jvRequest["seed"].asString()))
|
||||||
{
|
{
|
||||||
return rpcError(rpcBAD_SEED);
|
return rpcError(rpcBAD_SEED);
|
||||||
}
|
}
|
||||||
@@ -1537,10 +1535,10 @@ Json::Value RPCHandler::doLogLevel(Json::Value params)
|
|||||||
// node: <domain>|<node_public>,
|
// node: <domain>|<node_public>,
|
||||||
// comment: <comment> // optional
|
// comment: <comment> // optional
|
||||||
// }
|
// }
|
||||||
Json::Value RPCHandler::doUnlAdd(Json::Value jvParams)
|
Json::Value RPCHandler::doUnlAdd(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
std::string strNode = jvParams.isMember("node") ? jvParams["node"].asString() : "";
|
std::string strNode = jvRequest.isMember("node") ? jvRequest["node"].asString() : "";
|
||||||
std::string strComment = jvParams.isMember("comment") ? jvParams["comment"].asString() : "";
|
std::string strComment = jvRequest.isMember("comment") ? jvRequest["comment"].asString() : "";
|
||||||
|
|
||||||
RippleAddress raNodePublic;
|
RippleAddress raNodePublic;
|
||||||
|
|
||||||
@@ -1561,9 +1559,9 @@ Json::Value RPCHandler::doUnlAdd(Json::Value jvParams)
|
|||||||
// {
|
// {
|
||||||
// node: <domain>|<public_key>
|
// node: <domain>|<public_key>
|
||||||
// }
|
// }
|
||||||
Json::Value RPCHandler::doUnlDelete(Json::Value jvParams)
|
Json::Value RPCHandler::doUnlDelete(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
std::string strNode = jvParams[0u].asString();
|
std::string strNode = jvRequest[0u].asString();
|
||||||
|
|
||||||
RippleAddress raNodePublic;
|
RippleAddress raNodePublic;
|
||||||
|
|
||||||
@@ -2181,15 +2179,15 @@ Json::Value RPCHandler::doRpcCommand(const std::string& strCommand, Json::Value&
|
|||||||
return jvResult;
|
return jvResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
Json::Value RPCHandler::doCommand(Json::Value& jvRequest, int iRole)
|
||||||
{
|
{
|
||||||
if (!jvParams.isMember("command"))
|
if (!jvRequest.isMember("command"))
|
||||||
return rpcError(rpcINVALID_PARAMS);
|
return rpcError(rpcINVALID_PARAMS);
|
||||||
|
|
||||||
std::string strCommand = jvParams["command"].asString();
|
std::string strCommand = jvRequest["command"].asString();
|
||||||
|
|
||||||
cLog(lsTRACE) << "COMMAND:" << strCommand;
|
cLog(lsTRACE) << "COMMAND:" << strCommand;
|
||||||
cLog(lsTRACE) << "REQUEST:" << jvParams;
|
cLog(lsTRACE) << "REQUEST:" << jvRequest;
|
||||||
|
|
||||||
LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC));
|
LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC));
|
||||||
|
|
||||||
@@ -2198,63 +2196,61 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
|||||||
static struct {
|
static struct {
|
||||||
const char* pCommand;
|
const char* pCommand;
|
||||||
doFuncPtr dfpFunc;
|
doFuncPtr dfpFunc;
|
||||||
int iMinParams;
|
|
||||||
int iMaxParams;
|
|
||||||
bool bAdminRequired;
|
bool bAdminRequired;
|
||||||
bool bEvented;
|
bool bEvented;
|
||||||
unsigned int iOptions;
|
unsigned int iOptions;
|
||||||
} commandsA[] = {
|
} commandsA[] = {
|
||||||
// Request-response methods
|
// Request-response methods
|
||||||
{ "accept_ledger", &RPCHandler::doAcceptLedger, -1, -1, true, false, optCurrent },
|
{ "accept_ledger", &RPCHandler::doAcceptLedger, true, false, optCurrent },
|
||||||
{ "account_info", &RPCHandler::doAccountInfo, -1, -1, false, false, optCurrent },
|
{ "account_info", &RPCHandler::doAccountInfo, false, false, optCurrent },
|
||||||
{ "account_tx", &RPCHandler::doAccountTransactions,-1, -1, false, false, optNetwork },
|
{ "account_tx", &RPCHandler::doAccountTransactions, false, false, optNetwork },
|
||||||
{ "connect", &RPCHandler::doConnect, -1, -1, true, false, optNone },
|
{ "connect", &RPCHandler::doConnect, true, false, optNone },
|
||||||
{ "get_counts", &RPCHandler::doGetCounts, -1, -1, true, false, optNone },
|
{ "get_counts", &RPCHandler::doGetCounts, true, false, optNone },
|
||||||
{ "ledger", &RPCHandler::doLedger, -1, -1, false, false, optNetwork },
|
{ "ledger", &RPCHandler::doLedger, false, false, optNetwork },
|
||||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, -1, -1, true, false, optCurrent },
|
{ "ledger_accept", &RPCHandler::doLedgerAccept, true, false, optCurrent },
|
||||||
{ "ledger_closed", &RPCHandler::doLedgerClosed, -1, -1, false, false, optClosed },
|
{ "ledger_closed", &RPCHandler::doLedgerClosed, false, false, optClosed },
|
||||||
{ "ledger_current", &RPCHandler::doLedgerCurrent, -1, -1, false, false, optCurrent },
|
{ "ledger_current", &RPCHandler::doLedgerCurrent, false, false, optCurrent },
|
||||||
{ "ledger_entry", &RPCHandler::doLedgerEntry, -1, -1, false, false, optCurrent },
|
{ "ledger_entry", &RPCHandler::doLedgerEntry, false, false, optCurrent },
|
||||||
{ "ledger_header", &RPCHandler::doLedgerHeader, -1, -1, false, false, optCurrent },
|
{ "ledger_header", &RPCHandler::doLedgerHeader, false, false, optCurrent },
|
||||||
{ "log_level", &RPCHandler::doLogLevel, 0, 2, true, false, optNone },
|
{ "log_level", &RPCHandler::doLogLevel, true, false, optNone },
|
||||||
{ "logrotate", &RPCHandler::doLogRotate, -1, -1, true, false, optNone },
|
{ "logrotate", &RPCHandler::doLogRotate, true, false, optNone },
|
||||||
// { "nickname_info", &RPCHandler::doNicknameInfo, 1, 1, false, false, optCurrent },
|
// { "nickname_info", &RPCHandler::doNicknameInfo, false, false, optCurrent },
|
||||||
{ "owner_info", &RPCHandler::doOwnerInfo, -1, -1, false, false, optCurrent },
|
{ "owner_info", &RPCHandler::doOwnerInfo, false, false, optCurrent },
|
||||||
{ "peers", &RPCHandler::doPeers, -1, -1, true, false, optNone },
|
{ "peers", &RPCHandler::doPeers, true, false, optNone },
|
||||||
// { "profile", &RPCHandler::doProfile, -1, -1, false, false, optCurrent },
|
// { "profile", &RPCHandler::doProfile, false, false, optCurrent },
|
||||||
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, -1, -1, false, false, optCurrent },
|
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, false, false, optCurrent },
|
||||||
{ "ripple_path_find", &RPCHandler::doRipplePathFind, -1, -1, false, false, optCurrent },
|
{ "ripple_path_find", &RPCHandler::doRipplePathFind, false, false, optCurrent },
|
||||||
{ "submit", &RPCHandler::doSubmit, -1, -1, false, false, optCurrent },
|
{ "submit", &RPCHandler::doSubmit, false, false, optCurrent },
|
||||||
{ "server_info", &RPCHandler::doServerInfo, -1, -1, true, false, optNone },
|
{ "server_info", &RPCHandler::doServerInfo, true, false, optNone },
|
||||||
{ "stop", &RPCHandler::doStop, -1, -1, true, false, optNone },
|
{ "stop", &RPCHandler::doStop, true, false, optNone },
|
||||||
{ "transaction_entry", &RPCHandler::doTransactionEntry, -1, -1, false, false, optCurrent },
|
{ "transaction_entry", &RPCHandler::doTransactionEntry, false, false, optCurrent },
|
||||||
{ "tx", &RPCHandler::doTx, -1, -1, true, false, optNone },
|
{ "tx", &RPCHandler::doTx, true, false, optNone },
|
||||||
{ "tx_history", &RPCHandler::doTxHistory, 1, 1, false, false, optNone },
|
{ "tx_history", &RPCHandler::doTxHistory, false, false, optNone },
|
||||||
|
|
||||||
{ "unl_add", &RPCHandler::doUnlAdd, -1, -1, true, false, optNone },
|
{ "unl_add", &RPCHandler::doUnlAdd, true, false, optNone },
|
||||||
{ "unl_delete", &RPCHandler::doUnlDelete, -1, -1, true, false, optNone },
|
{ "unl_delete", &RPCHandler::doUnlDelete, true, false, optNone },
|
||||||
{ "unl_list", &RPCHandler::doUnlList, -1, -1, true, false, optNone },
|
{ "unl_list", &RPCHandler::doUnlList, true, false, optNone },
|
||||||
{ "unl_load", &RPCHandler::doUnlLoad, -1, -1, true, false, optNone },
|
{ "unl_load", &RPCHandler::doUnlLoad, true, false, optNone },
|
||||||
{ "unl_network", &RPCHandler::doUnlNetwork, -1, -1, true, false, optNone },
|
{ "unl_network", &RPCHandler::doUnlNetwork, true, false, optNone },
|
||||||
{ "unl_reset", &RPCHandler::doUnlReset, -1, -1, true, false, optNone },
|
{ "unl_reset", &RPCHandler::doUnlReset, true, false, optNone },
|
||||||
{ "unl_score", &RPCHandler::doUnlScore, -1, -1, true, false, optNone },
|
{ "unl_score", &RPCHandler::doUnlScore, true, false, optNone },
|
||||||
|
|
||||||
{ "validation_create", &RPCHandler::doValidationCreate, -1, -1, false, false, optNone },
|
{ "validation_create", &RPCHandler::doValidationCreate, false, false, optNone },
|
||||||
{ "validation_seed", &RPCHandler::doValidationSeed, -1, -1, false, false, optNone },
|
{ "validation_seed", &RPCHandler::doValidationSeed, false, false, optNone },
|
||||||
|
|
||||||
{ "wallet_accounts", &RPCHandler::doWalletAccounts, -1, -1, false, false, optCurrent },
|
{ "wallet_accounts", &RPCHandler::doWalletAccounts, false, false, optCurrent },
|
||||||
{ "wallet_propose", &RPCHandler::doWalletPropose, -1, -1, false, false, optNone },
|
{ "wallet_propose", &RPCHandler::doWalletPropose, false, false, optNone },
|
||||||
{ "wallet_seed", &RPCHandler::doWalletSeed, -1, -1, false, false, optNone },
|
{ "wallet_seed", &RPCHandler::doWalletSeed, false, false, optNone },
|
||||||
|
|
||||||
// XXX Unnecessary commands which should be removed.
|
// XXX Unnecessary commands which should be removed.
|
||||||
{ "login", &RPCHandler::doLogin, -1, -1, true, false, optNone },
|
{ "login", &RPCHandler::doLogin, true, false, optNone },
|
||||||
{ "data_delete", &RPCHandler::doDataDelete, -1, -1, true, false, optNone },
|
{ "data_delete", &RPCHandler::doDataDelete, true, false, optNone },
|
||||||
{ "data_fetch", &RPCHandler::doDataFetch, -1, -1, true, false, optNone },
|
{ "data_fetch", &RPCHandler::doDataFetch, true, false, optNone },
|
||||||
{ "data_store", &RPCHandler::doDataStore, -1, -1, true, false, optNone },
|
{ "data_store", &RPCHandler::doDataStore, true, false, optNone },
|
||||||
|
|
||||||
// Evented methods
|
// Evented methods
|
||||||
{ "subscribe", &RPCHandler::doSubscribe, -1, -1, false, true, optNone },
|
{ "subscribe", &RPCHandler::doSubscribe, false, true, optNone },
|
||||||
{ "unsubscribe", &RPCHandler::doUnsubscribe, -1, -1, false, true, optNone },
|
{ "unsubscribe", &RPCHandler::doUnsubscribe, false, true, optNone },
|
||||||
};
|
};
|
||||||
|
|
||||||
int i = NUMBER(commandsA);
|
int i = NUMBER(commandsA);
|
||||||
@@ -2274,16 +2270,6 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
|||||||
{
|
{
|
||||||
return rpcError(rpcNO_EVENTS);
|
return rpcError(rpcNO_EVENTS);
|
||||||
}
|
}
|
||||||
else if (commandsA[i].iMinParams >= 0
|
|
||||||
? commandsA[i].iMaxParams
|
|
||||||
? (jvParams.size() < commandsA[i].iMinParams
|
|
||||||
|| (commandsA[i].iMaxParams >= 0 && jvParams.size() > commandsA[i].iMaxParams))
|
|
||||||
: false
|
|
||||||
: jvParams.isArray())
|
|
||||||
{
|
|
||||||
cLog(lsDEBUG) << "params.size: " << jvParams.size() << " array: " << jvParams.isArray();
|
|
||||||
return rpcError(rpcINVALID_PARAMS);
|
|
||||||
}
|
|
||||||
else if ((commandsA[i].iOptions & optNetwork) && !mNetOps->available())
|
else if ((commandsA[i].iOptions & optNetwork) && !mNetOps->available())
|
||||||
{
|
{
|
||||||
return rpcError(rpcNO_NETWORK);
|
return rpcError(rpcNO_NETWORK);
|
||||||
@@ -2302,7 +2288,7 @@ cLog(lsDEBUG) << "params.size: " << jvParams.size() << " array: " << jvParams.is
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Json::Value jvRaw = (this->*(commandsA[i].dfpFunc))(jvParams);
|
Json::Value jvRaw = (this->*(commandsA[i].dfpFunc))(jvRequest);
|
||||||
|
|
||||||
// Regularize result.
|
// Regularize result.
|
||||||
if (jvRaw.isObject())
|
if (jvRaw.isObject())
|
||||||
|
|||||||
Reference in New Issue
Block a user