Static feature support.

This commit is contained in:
JoelKatz
2013-05-29 11:54:20 -07:00
parent 606b2a2942
commit 76358edc31
3 changed files with 26 additions and 16 deletions

View File

@@ -429,6 +429,8 @@ void Application::startNewLedger()
{
Ledger::pointer firstLedger = boost::make_shared<Ledger>(rootAddress, SYSTEM_CURRENCY_START);
assert(!!firstLedger->getAccountState(rootAddress));
// WRITEME: Add any default features
// WRITEME: Set default fee/reserve
firstLedger->updateHash();
firstLedger->setClosed();
firstLedger->setAccepted();

View File

@@ -3,11 +3,11 @@ SETUP_LOG (FeatureTable)
void FeatureTable::addInitialFeatures()
{
// For each feature this version supports, call enableFeature.
// Permanent vetos can also be added here.
// 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
}
FeatureTable::FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create)
FeatureState* FeatureTable::getCreateFeature(const uint256& featureHash, bool create)
{ // call with the mutex held
featureMap_t::iterator it = mFeatureMap.find(featureHash);
if (it == mFeatureMap.end())

View File

@@ -18,22 +18,30 @@ public:
void addVote(const uint256& feature) { ++mVotes[feature]; }
};
class FeatureTable
class FeatureState
{
protected:
class FeatureState
{
public:
public:
uint256 mHash; // Feature hash
bool mVetoed; // We don't want this feature enabled
bool mEnabled;
bool mSupported;
bool mDefault; // Include in genesis ledger
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), mSupported(false), mFirstMajority(0), mLastMajority(0) { ; }
};
FeatureState()
: mVetoed(false), mEnabled(false), mSupported(false), mDefault(false),
mFirstMajority(0), mLastMajority(0) { ; }
void setVeto() { mVetoed = true; }
void setDefault() { mDefault = true; }
};
class FeatureTable
{
protected:
typedef boost::unordered_map<uint256, FeatureState> featureMap_t;
typedef std::pair<const uint256, FeatureState> featureIt_t;