mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
More change process work.
This commit is contained in:
@@ -57,6 +57,7 @@ Application::Application() :
|
||||
mSNTPClient(mAuxService), mJobQueue(mIOService), mFeeTrack(),
|
||||
|
||||
mFeeVote(10, 50 * SYSTEM_CURRENCY_PARTS, 12.5 * SYSTEM_CURRENCY_PARTS),
|
||||
mFeatureTable(2 * 7 * 24 * 60 * 60, 200), // two weeks, 200/256
|
||||
|
||||
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
|
||||
mNetNodeDB(NULL), mPathFindDB(NULL), mHashNodeDB(NULL),
|
||||
|
||||
@@ -77,6 +77,7 @@ class Application
|
||||
TXQueue mTxnQueue;
|
||||
OrderBookDB mOrderBookDB;
|
||||
FeeVote mFeeVote;
|
||||
FeatureTable mFeatureTable;
|
||||
|
||||
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB;
|
||||
|
||||
@@ -137,6 +138,7 @@ public:
|
||||
OrderBookDB& getOrderBookDB() { return mOrderBookDB; }
|
||||
SLECache& getSLECache() { return mSLECache; }
|
||||
FeeVote& getFeeVote() { return mFeeVote; }
|
||||
FeatureTable& getFeatureTable() { return mFeatureTable; }
|
||||
|
||||
|
||||
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }
|
||||
|
||||
@@ -125,6 +125,18 @@ FeatureTable::featureList_t FeatureTable::getFeaturesToEnable(uint32 closeTime)
|
||||
return ret;
|
||||
}
|
||||
|
||||
FeatureTable::featureList_t FeatureTable::getDesiredFeatures()
|
||||
{
|
||||
featureList_t ret;
|
||||
boost::mutex::scoped_lock sl(mMutex);
|
||||
BOOST_FOREACH(const featureIt_t& it, mFeatureMap)
|
||||
{
|
||||
if (it.second.mSupported && !it.second.mEnabled && !it.second.mVetoed)
|
||||
ret.insert(it.first);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FeatureTable::reportValidations(const FeatureSet& set)
|
||||
{
|
||||
if (set.mTrustedValidations == 0)
|
||||
@@ -189,6 +201,47 @@ void FeatureTable::setSupportedFeatures(const std::vector<uint256>& features)
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureTable::doValidation(Ledger::ref lastClosedLedger, STObject& baseValidation)
|
||||
{
|
||||
featureList_t lFeatures = getDesiredFeatures();
|
||||
if (lFeatures.empty())
|
||||
return;
|
||||
|
||||
STVector256 vFeatures(sfFeatures);
|
||||
BOOST_FOREACH(const uint256& uFeature, lFeatures)
|
||||
{
|
||||
vFeatures.addValue(uFeature);
|
||||
}
|
||||
vFeatures.sort();
|
||||
baseValidation.setFieldV256(sfFeatures, vFeatures);
|
||||
}
|
||||
|
||||
void FeatureTable::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition)
|
||||
{
|
||||
featureList_t lFeatures = getFeaturesToEnable(lastClosedLedger->getCloseTimeNC());
|
||||
if (lFeatures.empty())
|
||||
return;
|
||||
|
||||
BOOST_FOREACH(const uint256& uFeature, lFeatures)
|
||||
{
|
||||
cLog(lsWARNING) << "We are voting for feature " << uFeature;
|
||||
SerializedTransaction trans(ttFEATURE);
|
||||
trans.setFieldAccount(sfAccount, uint160());
|
||||
trans.setFieldH256(sfFeature, uFeature);
|
||||
uint256 txID = trans.getTransactionID();
|
||||
cLog(lsWARNING) << "Vote: " << txID;
|
||||
|
||||
Serializer s;
|
||||
trans.add(s, true);
|
||||
|
||||
SHAMapItem::pointer tItem = boost::make_shared<SHAMapItem>(txID, s.peekData());
|
||||
if (!initialPosition->addGiveItem(tItem, true, false))
|
||||
{
|
||||
cLog(lsWARNING) << "Ledger already had feature transaction";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value FeatureTable::getJson(int)
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
@@ -309,7 +362,7 @@ void FeeVote::doValidation(Ledger::ref lastClosedLedger, STObject& validation)
|
||||
}
|
||||
}
|
||||
|
||||
void FeeVote::doFeeVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition)
|
||||
void FeeVote::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition)
|
||||
{
|
||||
// LCL must be flag ledger
|
||||
assert((lastClosedLedger->getLedgerSeq() % 256) == 0);
|
||||
|
||||
@@ -71,10 +71,14 @@ public:
|
||||
featureList_t getVetoedFeatures();
|
||||
featureList_t getEnabledFeatures();
|
||||
featureList_t getFeaturesToEnable(uint32 closeTime); // gets features we would vote to enable
|
||||
featureList_t getDesiredFeatures(); // features we support, do not veto, are not enabled
|
||||
|
||||
void reportValidations(const FeatureSet&);
|
||||
|
||||
Json::Value getJson(int);
|
||||
|
||||
void doValidation(Ledger::ref lastClosedLedger, STObject& baseValidation);
|
||||
void doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition);
|
||||
};
|
||||
|
||||
class FeeVote
|
||||
@@ -97,7 +101,7 @@ public:
|
||||
void doValidation(Ledger::ref lastClosedLedger, STObject& baseValidation);
|
||||
|
||||
// vote on the fee we want
|
||||
void doFeeVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition);
|
||||
void doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -326,7 +326,8 @@ void LedgerConsensus::takeInitialPosition(Ledger& initialLedger)
|
||||
&& ((mPreviousLedger->getLedgerSeq() % 256) == 0))
|
||||
{ // previous ledger was flag ledger
|
||||
SHAMap::pointer preSet = initialLedger.peekTransactionMap()->snapShot(true);
|
||||
theApp->getFeeVote().doFeeVoting(mPreviousLedger, preSet);
|
||||
theApp->getFeeVote().doVoting(mPreviousLedger, preSet);
|
||||
theApp->getFeatureTable().doVoting(mPreviousLedger, preSet);
|
||||
initialSet = preSet->snapShot(false);
|
||||
}
|
||||
else
|
||||
@@ -1222,7 +1223,10 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
||||
(newLCLHash, theApp->getOPs().getValidationTimeNC(), mValPublic, mProposing);
|
||||
v->setFieldU32(sfLedgerSequence, newLCL->getLedgerSeq());
|
||||
if (((newLCL->getLedgerSeq() + 1) % 256) == 0) // next ledger is flag ledger
|
||||
{
|
||||
theApp->getFeeVote().doValidation(newLCL, *v);
|
||||
theApp->getFeatureTable().doValidation(newLCL, *v);
|
||||
}
|
||||
v->sign(signingHash, mValPrivate);
|
||||
v->setTrusted();
|
||||
theApp->isNew(signingHash); // suppress it if we receive it
|
||||
|
||||
@@ -871,6 +871,7 @@ public:
|
||||
void setValue(const std::vector<uint256>& v) { mValue = v; }
|
||||
void addValue(const uint256& v) { mValue.push_back(v); }
|
||||
bool hasValue(const uint256& v) const;
|
||||
void sort() { std::sort(mValue.begin(), mValue.end()); }
|
||||
|
||||
Json::Value getJson(int) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user