mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +00:00
Refactor RPC data_*.
This commit is contained in:
@@ -126,6 +126,37 @@ Json::Value RPCParser::parseConnect(const Json::Value& jvParams)
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// data_delete <key>
|
||||
Json::Value RPCParser::parseDataDelete(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value jvRequest(Json::objectValue);
|
||||
|
||||
jvRequest["key"] = jvParams[0u].asString();
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// data_fetch <key>
|
||||
Json::Value RPCParser::parseDataFetch(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value jvRequest(Json::objectValue);
|
||||
|
||||
jvRequest["key"] = jvParams[0u].asString();
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// data_store <key> <value>
|
||||
Json::Value RPCParser::parseDataStore(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value jvRequest(Json::objectValue);
|
||||
|
||||
jvRequest["key"] = jvParams[0u].asString();
|
||||
jvRequest["value"] = jvParams[1u].asString();
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// Return an error for attemping to subscribe/unsubscribe via RPC.
|
||||
Json::Value RPCParser::parseEvented(const Json::Value& jvParams)
|
||||
{
|
||||
@@ -376,9 +407,9 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
||||
|
||||
// XXX Unnecessary commands which should be removed.
|
||||
{ "login", &RPCParser::parseLogin, 2, 2 },
|
||||
// { "data_delete", &RPCParser::parseDataDelete, 1, 1, true, false, optNone },
|
||||
// { "data_fetch", &RPCParser::parseDataFetch, 1, 1, true, false, optNone },
|
||||
// { "data_store", &RPCParser::parseDataStore, 2, 2, true, false, optNone },
|
||||
{ "data_delete", &RPCParser::parseDataDelete, 1, 1 },
|
||||
{ "data_fetch", &RPCParser::parseDataFetch, 1, 1 },
|
||||
{ "data_store", &RPCParser::parseDataStore, 2, 2 },
|
||||
|
||||
// Evented methods
|
||||
{ "subscribe", &RPCParser::parseEvented, -1, -1 },
|
||||
|
||||
@@ -15,6 +15,9 @@ protected:
|
||||
Json::Value parseAccountTransactions(const Json::Value& jvParams);
|
||||
Json::Value parseAsIs(const Json::Value& jvParams);
|
||||
Json::Value parseConnect(const Json::Value& jvParams);
|
||||
Json::Value parseDataDelete(const Json::Value& jvParams);
|
||||
Json::Value parseDataFetch(const Json::Value& jvParams);
|
||||
Json::Value parseDataStore(const Json::Value& jvParams);
|
||||
Json::Value parseEvented(const Json::Value& jvParams);
|
||||
Json::Value parseGetCounts(const Json::Value& jvParams);
|
||||
Json::Value parseLedger(const Json::Value& jvParams);
|
||||
|
||||
@@ -340,10 +340,12 @@ Json::Value RPCHandler::doConnect(Json::Value jvParams)
|
||||
return "connecting";
|
||||
}
|
||||
|
||||
// data_delete <key>
|
||||
Json::Value RPCHandler::doDataDelete(Json::Value params)
|
||||
// {
|
||||
// key: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataDelete(Json::Value jvRequest)
|
||||
{
|
||||
std::string strKey = params[0u].asString();
|
||||
std::string strKey = jvRequest["key"].asString();
|
||||
|
||||
Json::Value ret = Json::Value(Json::objectValue);
|
||||
|
||||
@@ -359,10 +361,12 @@ Json::Value RPCHandler::doDataDelete(Json::Value params)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// data_fetch <key>
|
||||
Json::Value RPCHandler::doDataFetch(Json::Value params)
|
||||
// {
|
||||
// key: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataFetch(Json::Value jvRequest)
|
||||
{
|
||||
std::string strKey = params[0u].asString();
|
||||
std::string strKey = jvRequest["key"].asString();
|
||||
std::string strValue;
|
||||
|
||||
Json::Value ret = Json::Value(Json::objectValue);
|
||||
@@ -374,11 +378,14 @@ Json::Value RPCHandler::doDataFetch(Json::Value params)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// data_store <key> <value>
|
||||
Json::Value RPCHandler::doDataStore(Json::Value params)
|
||||
// {
|
||||
// key: <string>
|
||||
// value: <string>
|
||||
// }
|
||||
Json::Value RPCHandler::doDataStore(Json::Value jvRequest)
|
||||
{
|
||||
std::string strKey = params[0u].asString();
|
||||
std::string strValue = params[1u].asString();
|
||||
std::string strKey = jvRequest["key"].asString();
|
||||
std::string strValue = jvRequest["value"].asString();
|
||||
|
||||
Json::Value ret = Json::Value(Json::objectValue);
|
||||
|
||||
@@ -2239,9 +2246,9 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
||||
|
||||
// XXX Unnecessary commands which should be removed.
|
||||
{ "login", &RPCHandler::doLogin, -1, -1, true, false, optNone },
|
||||
{ "data_delete", &RPCHandler::doDataDelete, 1, 1, true, false, optNone },
|
||||
{ "data_fetch", &RPCHandler::doDataFetch, 1, 1, true, false, optNone },
|
||||
{ "data_store", &RPCHandler::doDataStore, 2, 2, true, false, optNone },
|
||||
{ "data_delete", &RPCHandler::doDataDelete, -1, -1, true, false, optNone },
|
||||
{ "data_fetch", &RPCHandler::doDataFetch, -1, -1, true, false, optNone },
|
||||
{ "data_store", &RPCHandler::doDataStore, -1, -1, true, false, optNone },
|
||||
|
||||
// Evented methods
|
||||
{ "subscribe", &RPCHandler::doSubscribe, -1, -1, false, true, optNone },
|
||||
|
||||
Reference in New Issue
Block a user