diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp index 89f2ed4e20..6a6ee9f3a9 100644 --- a/src/cpp/ripple/CallRPC.cpp +++ b/src/cpp/ripple/CallRPC.cpp @@ -310,6 +310,20 @@ Json::Value RPCParser::parseEvented(const Json::Value& jvParams) return rpcError(rpcNO_EVENTS); } +// 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(jvParams[1u].asString()); + + return jvRequest; +} + // get_counts [] 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 }, { "connect", &RPCParser::parseConnect, 1, 2 }, { "consensus_info", &RPCParser::parseAsIs, 0, 0 }, + { "feature", &RPCParser::parseFeature, 0, 2 }, { "get_counts", &RPCParser::parseGetCounts, 0, 1 }, { "json", &RPCParser::parseJson, 2, 2 }, { "ledger", &RPCParser::parseLedger, 0, 2 }, diff --git a/src/cpp/ripple/CallRPC.h b/src/cpp/ripple/CallRPC.h index 3ce69167a6..0ce9a86303 100644 --- a/src/cpp/ripple/CallRPC.h +++ b/src/cpp/ripple/CallRPC.h @@ -22,6 +22,7 @@ protected: Json::Value parseDataStore(const Json::Value& jvParams); #endif Json::Value parseEvented(const Json::Value& jvParams); + Json::Value parseFeature(const Json::Value& jvParams); Json::Value parseGetCounts(const Json::Value& jvParams); Json::Value parseInternal(const Json::Value& jvParams); Json::Value parseJson(const Json::Value& jvParams); diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp index d787f83263..e93a5821b4 100644 --- a/src/cpp/ripple/FeatureTable.cpp +++ b/src/cpp/ripple/FeatureTable.cpp @@ -1,10 +1,14 @@ SETUP_LOG (FeatureTable) +FeatureState* testFeature = NULL; + void FeatureTable::addInitialFeatures() { // 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 + + testFeature = getCreateFeature(uint256("1234"), true); } FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create) diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 398a702a5f..2f3f0d9661 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -2263,6 +2263,24 @@ static void textTime(std::string& text, int& seconds, const char *unitName, int 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: // 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 }, { "get_counts", &RPCHandler::doGetCounts, true, optNone }, { "internal", &RPCHandler::doInternal, true, optNone }, + { "feature", &RPCHandler::doFeature, true, optNone }, { "ledger", &RPCHandler::doLedger, false, optNetwork }, { "ledger_accept", &RPCHandler::doLedgerAccept, true, optCurrent }, { "ledger_closed", &RPCHandler::doLedgerClosed, false, optClosed }, diff --git a/src/cpp/ripple/RPCHandler.h b/src/cpp/ripple/RPCHandler.h index 298d76c605..14df015a98 100644 --- a/src/cpp/ripple/RPCHandler.h +++ b/src/cpp/ripple/RPCHandler.h @@ -57,6 +57,7 @@ class RPCHandler Json::Value doDataFetch(Json::Value params, int& cost, ScopedLock& mlh); Json::Value doDataStore(Json::Value params, int& cost, ScopedLock& mlh); #endif + Json::Value doFeature(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 doLedger(Json::Value params, int& cost, ScopedLock& mlh);