mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Clean up addition of initial features.
This commit is contained in:
@@ -8,8 +8,7 @@ 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);
|
||||
testFeature->setFriendlyName("testFeature");
|
||||
testFeature = addKnownFeature("1234", "testFeature", false);
|
||||
}
|
||||
|
||||
FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create)
|
||||
@@ -41,6 +40,26 @@ FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool cr
|
||||
return &(it->second);
|
||||
}
|
||||
|
||||
FeatureState* FeatureTable::addKnownFeature(const char *featureID, const char *friendlyName, bool veto)
|
||||
{
|
||||
uint256 hash;
|
||||
hash.SetHex(featureID);
|
||||
if (hash.isZero())
|
||||
{
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
FeatureState* f = getCreateFeature(hash, true);
|
||||
|
||||
if (friendlyName != NULL)
|
||||
f->setFriendlyName(friendlyName);
|
||||
|
||||
f->mVetoed = veto;
|
||||
f->mSupported = true;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
bool FeatureTable::vetoFeature(const uint256& feature)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mMutex);
|
||||
@@ -304,6 +323,7 @@ Json::Value FeatureTable::getJson(int)
|
||||
v["name"] = it.second.mFriendlyName;
|
||||
|
||||
v["supported"] = it.second.mSupported;
|
||||
v["vetoed"] = it.second.mVetoed;
|
||||
|
||||
if (it.second.mEnabled)
|
||||
v["enabled"] = true;
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
|
||||
void addInitialFeatures();
|
||||
|
||||
FeatureState* addKnownFeature(const char *featureID, const char *friendlyName, bool veto);
|
||||
|
||||
bool vetoFeature(const uint256& feature);
|
||||
bool unVetoFeature(const uint256& feature);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user