mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
More feature table work.
This commit is contained in:
@@ -160,6 +160,19 @@ void FeatureTable::reportValidations(const FeatureSet& set)
|
||||
mLastReport = set.mCloseTime;
|
||||
}
|
||||
|
||||
void FeatureTable::setEnabledFeatures(const std::vector<uint256>& 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
|
||||
|
||||
@@ -37,7 +37,7 @@ protected:
|
||||
};
|
||||
|
||||
typedef boost::unordered_map<uint256, FeatureState> featureMap_t;
|
||||
typedef std::pair<uint256, FeatureState> featureIt_t;
|
||||
typedef std::pair<const uint256, FeatureState> featureIt_t;
|
||||
typedef boost::unordered_set<uint256> featureList_t;
|
||||
|
||||
boost::mutex mMutex;
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
|
||||
bool isFeatureEnabled(const uint256& feature);
|
||||
|
||||
void setEnabledFeatures(const std::vector<uint256>& features);
|
||||
|
||||
featureList_t getVetoedFeatures();
|
||||
featureList_t getEnabledFeatures();
|
||||
featureList_t getFeaturesToEnable(uint32 closeTime); // gets features we would vote to enable
|
||||
|
||||
Reference in New Issue
Block a user