From c8159e70ebf1162fbcd44a26e8e5eb36fcd59e85 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 2 Dec 2012 21:15:59 -0800 Subject: [PATCH] Missing piece. --- src/cpp/ripple/FeatureTable.cpp | 19 +++++++++++++++++-- src/cpp/ripple/FeatureTable.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp index b89ede4974..984be60d0e 100644 --- a/src/cpp/ripple/FeatureTable.cpp +++ b/src/cpp/ripple/FeatureTable.cpp @@ -91,7 +91,7 @@ FeatureTable::featureList_t FeatureTable::getEnabledFeatures() bool FeatureTable::shouldEnable(uint32 closeTime, const FeatureState& fs) { - if (fs.mVetoed || fs.mEnabled || (fs.mLastMajority != mLastReport)) + if (fs.mVetoed || fs.mEnabled || !fs.mSupported || (fs.mLastMajority != mLastReport)) return false; if (fs.mFirstMajority == mFirstReport) @@ -116,7 +116,7 @@ FeatureTable::featureList_t FeatureTable::getFeaturesToEnable(uint32 closeTime) BOOST_FOREACH(const featureIt_t& it, mFeatureMap) { if (shouldEnable(closeTime, it.second)) - ret.insert(it.first); + ret.insert(it.first); } } return ret; @@ -173,6 +173,19 @@ void FeatureTable::setEnabledFeatures(const std::vector& features) } } +void FeatureTable::setSupportedFeatures(const std::vector& features) +{ + boost::mutex::scoped_lock sl(mMutex); + BOOST_FOREACH(featureIt_t& it, mFeatureMap) + { + it.second.mSupported = false; + } + BOOST_FOREACH(const uint256& it, features) + { + mFeatureMap[it].mSupported = true; + } +} + Json::Value FeatureTable::getJson(int) { Json::Value ret(Json::objectValue); @@ -182,6 +195,8 @@ Json::Value FeatureTable::getJson(int) { Json::Value v(Json::objectValue); + v["supported"] = it.second.mSupported ? "true" : "false"; + if (it.second.mEnabled) v["enabled"] = "true"; else diff --git a/src/cpp/ripple/FeatureTable.h b/src/cpp/ripple/FeatureTable.h index 1b011ac9ca..d52b7aaa9e 100644 --- a/src/cpp/ripple/FeatureTable.h +++ b/src/cpp/ripple/FeatureTable.h @@ -29,11 +29,12 @@ protected: public: bool mVetoed; // We don't want this feature enabled bool mEnabled; + bool mSupported; uint32 mFirstMajority; // First time we saw a majority (close time) uint32 mLastMajority; // Most recent time we saw a majority (close time) - FeatureState() : mVetoed(false), mEnabled(false), mFirstMajority(0), mLastMajority(0) { ; } + FeatureState() : mVetoed(false), mEnabled(false), mSupported(false), mFirstMajority(0), mLastMajority(0) { ; } }; typedef boost::unordered_map featureMap_t; @@ -65,6 +66,7 @@ public: bool isFeatureEnabled(const uint256& feature); void setEnabledFeatures(const std::vector& features); + void setSupportedFeatures(const std::vector& features); featureList_t getVetoedFeatures(); featureList_t getEnabledFeatures();