mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 04:25:51 +00:00
RPC infrastructure for feature management.
This commit is contained in:
@@ -310,6 +310,20 @@ Json::Value RPCParser::parseEvented(const Json::Value& jvParams)
|
|||||||
return rpcError(rpcNO_EVENTS);
|
return rpcError(rpcNO_EVENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// feature [<feature>] [true|false]
|
||||||
|
Json::Value RPCParser::parseFeature(const Json::Value& jvParams)
|
||||||
|
{
|
||||||
|
Json::Value jvRequest(Json::objectValue);
|
||||||
|
|
||||||
|
if (jvParams.size() > 0)
|
||||||
|
jvRequest["feature"] = jvParams[0u].asString();
|
||||||
|
|
||||||
|
if (jvParams.size() > 1)
|
||||||
|
jvRequest["vote"] = boost::lexical_cast<bool>(jvParams[1u].asString());
|
||||||
|
|
||||||
|
return jvRequest;
|
||||||
|
}
|
||||||
|
|
||||||
// get_counts [<min_count>]
|
// get_counts [<min_count>]
|
||||||
Json::Value RPCParser::parseGetCounts(const Json::Value& jvParams)
|
Json::Value RPCParser::parseGetCounts(const Json::Value& jvParams)
|
||||||
{
|
{
|
||||||
@@ -733,6 +747,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
{ "book_offers", &RPCParser::parseBookOffers, 2, 7 },
|
{ "book_offers", &RPCParser::parseBookOffers, 2, 7 },
|
||||||
{ "connect", &RPCParser::parseConnect, 1, 2 },
|
{ "connect", &RPCParser::parseConnect, 1, 2 },
|
||||||
{ "consensus_info", &RPCParser::parseAsIs, 0, 0 },
|
{ "consensus_info", &RPCParser::parseAsIs, 0, 0 },
|
||||||
|
{ "feature", &RPCParser::parseFeature, 0, 2 },
|
||||||
{ "get_counts", &RPCParser::parseGetCounts, 0, 1 },
|
{ "get_counts", &RPCParser::parseGetCounts, 0, 1 },
|
||||||
{ "json", &RPCParser::parseJson, 2, 2 },
|
{ "json", &RPCParser::parseJson, 2, 2 },
|
||||||
{ "ledger", &RPCParser::parseLedger, 0, 2 },
|
{ "ledger", &RPCParser::parseLedger, 0, 2 },
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ protected:
|
|||||||
Json::Value parseDataStore(const Json::Value& jvParams);
|
Json::Value parseDataStore(const Json::Value& jvParams);
|
||||||
#endif
|
#endif
|
||||||
Json::Value parseEvented(const Json::Value& jvParams);
|
Json::Value parseEvented(const Json::Value& jvParams);
|
||||||
|
Json::Value parseFeature(const Json::Value& jvParams);
|
||||||
Json::Value parseGetCounts(const Json::Value& jvParams);
|
Json::Value parseGetCounts(const Json::Value& jvParams);
|
||||||
Json::Value parseInternal(const Json::Value& jvParams);
|
Json::Value parseInternal(const Json::Value& jvParams);
|
||||||
Json::Value parseJson(const Json::Value& jvParams);
|
Json::Value parseJson(const Json::Value& jvParams);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
|
|
||||||
SETUP_LOG (FeatureTable)
|
SETUP_LOG (FeatureTable)
|
||||||
|
|
||||||
|
FeatureState* testFeature = NULL;
|
||||||
|
|
||||||
void FeatureTable::addInitialFeatures()
|
void FeatureTable::addInitialFeatures()
|
||||||
{
|
{
|
||||||
// For each feature this version supports, construct the FeatureState object by calling
|
// For each feature this version supports, construct the FeatureState object by calling
|
||||||
// getCreateFeature. Set any vetoes or defaults. A pointer to the FeatureState can be stashed
|
// getCreateFeature. Set any vetoes or defaults. A pointer to the FeatureState can be stashed
|
||||||
|
|
||||||
|
testFeature = getCreateFeature(uint256("1234"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create)
|
FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create)
|
||||||
|
|||||||
@@ -2263,6 +2263,24 @@ static void textTime(std::string& text, int& seconds, const char *unitName, int
|
|||||||
text += "s";
|
text += "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Json::Value RPCHandler::doFeature(Json::Value jvRequest, int& cost, ScopedLock& mlh)
|
||||||
|
{
|
||||||
|
if (!jvRequest.isMember("feature"))
|
||||||
|
{
|
||||||
|
Json::Value jvReply = Json::objectValue;
|
||||||
|
jvReply["features"] = theApp->getFeatureTable().getJson(0);
|
||||||
|
return jvReply;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jvRequest.isMember("vote"))
|
||||||
|
{
|
||||||
|
// WRITEME
|
||||||
|
}
|
||||||
|
|
||||||
|
// WRITEME
|
||||||
|
return rpcError(rpcNOT_SUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// min_count: <number> // optional, defaults to 10
|
// min_count: <number> // optional, defaults to 10
|
||||||
// }
|
// }
|
||||||
@@ -3469,6 +3487,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int &
|
|||||||
{ "consensus_info", &RPCHandler::doConsensusInfo, true, optNone },
|
{ "consensus_info", &RPCHandler::doConsensusInfo, true, optNone },
|
||||||
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
{ "get_counts", &RPCHandler::doGetCounts, true, optNone },
|
||||||
{ "internal", &RPCHandler::doInternal, true, optNone },
|
{ "internal", &RPCHandler::doInternal, true, optNone },
|
||||||
|
{ "feature", &RPCHandler::doFeature, true, optNone },
|
||||||
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
{ "ledger", &RPCHandler::doLedger, false, optNetwork },
|
||||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, true, optCurrent },
|
{ "ledger_accept", &RPCHandler::doLedgerAccept, true, optCurrent },
|
||||||
{ "ledger_closed", &RPCHandler::doLedgerClosed, false, optClosed },
|
{ "ledger_closed", &RPCHandler::doLedgerClosed, false, optClosed },
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class RPCHandler
|
|||||||
Json::Value doDataFetch(Json::Value params, int& cost, ScopedLock& mlh);
|
Json::Value doDataFetch(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
Json::Value doDataStore(Json::Value params, int& cost, ScopedLock& mlh);
|
Json::Value doDataStore(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
#endif
|
#endif
|
||||||
|
Json::Value doFeature(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
Json::Value doGetCounts(Json::Value params, int& cost, ScopedLock& mlh);
|
Json::Value doGetCounts(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
Json::Value doInternal(Json::Value params, int& cost, ScopedLock& mlh);
|
Json::Value doInternal(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
Json::Value doLedger(Json::Value params, int& cost, ScopedLock& mlh);
|
Json::Value doLedger(Json::Value params, int& cost, ScopedLock& mlh);
|
||||||
|
|||||||
Reference in New Issue
Block a user