diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp index e5652a758b..b89ede4974 100644 --- a/src/cpp/ripple/FeatureTable.cpp +++ b/src/cpp/ripple/FeatureTable.cpp @@ -160,6 +160,19 @@ void FeatureTable::reportValidations(const FeatureSet& set) mLastReport = set.mCloseTime; } +void FeatureTable::setEnabledFeatures(const std::vector& features) +{ + boost::mutex::scoped_lock sl(mMutex); + BOOST_FOREACH(featureIt_t& it, mFeatureMap) + { + it.second.mEnabled = false; + } + BOOST_FOREACH(const uint256& it, features) + { + mFeatureMap[it].mEnabled = true; + } +} + Json::Value FeatureTable::getJson(int) { Json::Value ret(Json::objectValue); @@ -168,10 +181,44 @@ Json::Value FeatureTable::getJson(int) BOOST_FOREACH(const featureIt_t& it, mFeatureMap) { Json::Value v(Json::objectValue); - // WRITEME + + if (it.second.mEnabled) + v["enabled"] = "true"; + else + { + v["enabled"] = "false"; + if (mLastReport != 0) + { + if (it.second.mLastMajority == 0) + v["majority"] = "no"; + else + { + if (it.second.mFirstMajority != 0) + { + if (it.second.mFirstMajority == mFirstReport) + v["majority_start"] = "start"; + else + v["majority_start"] = it.second.mFirstMajority; + } + if (it.second.mLastMajority != 0) + { + if (it.second.mLastMajority == mLastReport) + v["majority_until"] = "now"; + else + v["majority_until"] = it.second.mLastMajority; + } + } + } + } + + if (it.second.mVetoed) + v["veto"] = "true"; + ret[it.first.GetHex()] = v; } } return ret; } + +// vim:ts=4 diff --git a/src/cpp/ripple/FeatureTable.h b/src/cpp/ripple/FeatureTable.h index 4fba5a2765..1b011ac9ca 100644 --- a/src/cpp/ripple/FeatureTable.h +++ b/src/cpp/ripple/FeatureTable.h @@ -37,7 +37,7 @@ protected: }; typedef boost::unordered_map featureMap_t; - typedef std::pair featureIt_t; + typedef std::pair featureIt_t; typedef boost::unordered_set featureList_t; boost::mutex mMutex; @@ -64,6 +64,8 @@ public: bool isFeatureEnabled(const uint256& feature); + void setEnabledFeatures(const std::vector& features); + featureList_t getVetoedFeatures(); featureList_t getEnabledFeatures(); featureList_t getFeaturesToEnable(uint32 closeTime); // gets features we would vote to enable