diff --git a/newcoin.vcxproj b/newcoin.vcxproj index cd9990a88..3a1261fff 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -112,6 +112,7 @@ + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index a4f8be012..8d4ed17ae 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -87,6 +87,9 @@ Source Files + + Source Files + Source Files diff --git a/ripple2010.vcxproj.filters b/ripple2010.vcxproj.filters index 14f56c632..dd67f928d 100644 --- a/ripple2010.vcxproj.filters +++ b/ripple2010.vcxproj.filters @@ -84,6 +84,9 @@ Source Files + + Source Files + Source Files diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp index 2b91535ca..bb768d716 100644 --- a/src/cpp/ripple/Application.cpp +++ b/src/cpp/ripple/Application.cpp @@ -26,6 +26,8 @@ Application* theApp = NULL; int DatabaseCon::sCount = 0; +// #define RESERVE_BASE_100 + DatabaseCon::DatabaseCon(const std::string& strName, const char *initStrings[], int initCount) { ++sCount; @@ -50,6 +52,13 @@ Application::Application() : mIOWork(mIOService), mAuxWork(mAuxService), mUNL(mIOService), mNetOps(mIOService, &mLedgerMaster), mTempNodeCache("NodeCache", 16384, 90), mHashedObjectStore(16384, 300), mSLECache("LedgerEntryCache", 4096, 120), mSNTPClient(mAuxService), mJobQueue(mIOService), mFeeTrack(), + +#ifdef RESERVE_BASE_100 + mFeeVote(10, 100, 25), +#else + mFeeVote(10, 200, 50), +#endif + mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL), mPathFindDB(NULL), mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL), mWSPublicDoor(NULL), mWSPrivateDoor(NULL), diff --git a/src/cpp/ripple/Application.h b/src/cpp/ripple/Application.h index c8492e02a..356cce827 100644 --- a/src/cpp/ripple/Application.h +++ b/src/cpp/ripple/Application.h @@ -8,6 +8,7 @@ #include "LedgerMaster.h" #include "UniqueNodeList.h" #include "ConnectionPool.h" +#include "FeatureTable.h" #include "ScopedLock.h" #include "LedgerAcquire.h" #include "TransactionMaster.h" @@ -71,6 +72,7 @@ class Application LoadFeeTrack mFeeTrack; TXQueue mTxnQueue; OrderBookDB mOrderBookDB; + FeeVote mFeeVote; DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB, *mPathFindDB; @@ -124,6 +126,7 @@ public: PeerDoor& getPeerDoor() { return *mPeerDoor; } OrderBookDB& getOrderBookDB() { return mOrderBookDB; } SLECache& getSLECache() { return mSLECache; } + FeeVote& getFeeVote() { return mFeeVote; } bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); } diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp index af1d8349c..4c5808468 100644 --- a/src/cpp/ripple/FeatureTable.cpp +++ b/src/cpp/ripple/FeatureTable.cpp @@ -236,4 +236,64 @@ Json::Value FeatureTable::getJson(int) return ret; } +template class VotableInteger +{ +protected: + INT mCurrent; // The current setting + INT mTarget; // The setting we want + std::map mVoteMap; + + VotableInteger(INT current, INT target) : mCurrent(current), mTarget(target) + { + ++mVoteMap[mTarget]; // Add our vote + } + + bool mayVote() + { + return mCurrent != mTarget; // If we love the current setting, we will not vote + } + + void addVote(INT vote) + { + ++mVoteMap[vote]; + } + + void noVote() + { + addVote(mCurrent); + } + + INT getVotes() + { + INT ourVote = mCurrent; + int weight = 0; + + typedef std::pair INTint_pair_t; + BOOST_FOREACH(INTint_pair_t& value, mVoteMap) + { // Take most voted value between current and target, inclusive + if ((value.first <= std::max(mTarget, mCurrent)) && + (value.first >= std::min(mTarget, mCurrent)) && + (value.second > weight)) + { + ourVote = value.first; + weight = value.second; + } + } + + return ourVote; + } +}; + +void FeeVote::doFeeVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition) +{ + // LCL must be flag ledger + assert((lastClosedLedger->getLedgerSeq() % 256) == 0); + + // get validations for ledger before flag + + // choose our positions + + // add transactions to our position +} + // vim:ts=4 diff --git a/src/cpp/ripple/FeatureTable.h b/src/cpp/ripple/FeatureTable.h index d52b7aaa9..0f6403813 100644 --- a/src/cpp/ripple/FeatureTable.h +++ b/src/cpp/ripple/FeatureTable.h @@ -7,7 +7,7 @@ #include "../json/value.h" -#include "uint256.h" +#include "Ledger.h" class FeatureSet { // the status of all features requested in a given window @@ -77,4 +77,25 @@ public: Json::Value getJson(int); }; +class FeeVote +{ +protected: + + // What we'd like to see + uint64 mTargetBaseFee; + uint32 mTargetReserveBase, mTargetReserveIncrement; + + +public: + FeeVote(uint64 targetBaseFee, uint32 targetReserveBase, uint32 targetReserveIncrement) : + mTargetBaseFee(targetBaseFee), + mTargetReserveBase(targetReserveBase), + mTargetReserveIncrement(targetReserveIncrement) + { ; } + + void doValidation(STObject& baseValidation); + + void doFeeVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition); +}; + #endif