diff --git a/modules/ripple_ledger/ripple_ledger.cpp b/modules/ripple_ledger/ripple_ledger.cpp
index 90bcbbb9c..770bd7b0c 100644
--- a/modules/ripple_ledger/ripple_ledger.cpp
+++ b/modules/ripple_ledger/ripple_ledger.cpp
@@ -72,7 +72,6 @@
#include "src/cpp/ripple/CanonicalTXSet.h"
#include "src/cpp/ripple/ChangeTransactor.h"
#include "src/cpp/ripple/Config.h"
-#include "src/cpp/ripple/FeatureTable.h"
#include "src/cpp/ripple/HashPrefixes.h"
#include "src/cpp/ripple/Ledger.h"
#include "src/cpp/ripple/LedgerAcquire.h"
@@ -121,8 +120,17 @@
#include "src/cpp/ripple/Interpreter.h"
#include "src/cpp/ripple/Operation.h"
+
+// New abstract interfaces
+#include "src/cpp/ripple/ripple_IFeatures.h"
+#include "src/cpp/ripple/ripple_IFeeVote.h"
+#include "src/cpp/ripple/FeatureTable.h"
+
//------------------------------------------------------------------------------
+// main
+#include "src/cpp/ripple/Application.cpp"
+
// contracts
#include "src/cpp/ripple/Contract.cpp" // no log
#include "src/cpp/ripple/Interpreter.cpp" // no log
@@ -181,6 +189,10 @@
#include "src/cpp/ripple/Wallet.cpp"
#include "src/cpp/ripple/WalletAddTransactor.cpp"
+// Implementation of interfaces
+
+#include "src/cpp/ripple/ripple_FeeVote.cpp"
+
#ifdef _MSC_VER
//#pragma warning (pop)
#endif
diff --git a/modules/ripple_main/ripple_main.cpp b/modules/ripple_main/ripple_main.cpp
index 77809263d..e81ca6d1c 100644
--- a/modules/ripple_main/ripple_main.cpp
+++ b/modules/ripple_main/ripple_main.cpp
@@ -34,7 +34,6 @@
#pragma warning (disable: 4535) // call requires /EHa
#endif
-#include "src/cpp/ripple/Application.cpp"
#include "src/cpp/ripple/Config.cpp" // no log
#include "src/cpp/ripple/JobQueue.cpp"
#include "src/cpp/ripple/LoadManager.cpp"
diff --git a/newcoin.vcxproj b/newcoin.vcxproj
index cec35514d..6688de041 100644
--- a/newcoin.vcxproj
+++ b/newcoin.vcxproj
@@ -974,6 +974,12 @@
true
true
+
+ true
+ true
+ true
+ true
+
true
true
@@ -1634,6 +1640,8 @@
+
+
diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters
index ca7cc7004..ac7131916 100644
--- a/newcoin.vcxproj.filters
+++ b/newcoin.vcxproj.filters
@@ -136,6 +136,9 @@
{9f8ed40a-9f16-42fe-82fd-caf72d3d6a2b}
+
+ {1ccfc5ad-5cd7-4a8e-b305-08f663c2397c}
+
@@ -603,9 +606,6 @@
1. Modules\ripple_db\storage
-
- 1. Modules\ripple_main\_old
-
1. Modules\ripple_main\_old
@@ -786,6 +786,12 @@
1. Modules\ripple_data\protobuf
+
+ 1. Modules\ripple_ledger\processing
+
+
+ 1. Modules\ripple_ledger\main
+
@@ -1241,9 +1247,6 @@
1. Modules\ripple_db\storage
-
- 1. Modules\ripple_main\_old
-
1. Modules\ripple_main\_old
@@ -1460,6 +1463,15 @@
1. Modules\ripple_data\protobuf
+
+ 1. Modules\ripple_ledger\processing
+
+
+ 1. Modules\ripple_ledger\processing
+
+
+ 1. Modules\ripple_ledger\main
+
diff --git a/src/cpp/database/SqliteDatabase.h b/src/cpp/database/SqliteDatabase.h
index 0d9f248e4..4e2ab24a4 100644
--- a/src/cpp/database/SqliteDatabase.h
+++ b/src/cpp/database/SqliteDatabase.h
@@ -1,3 +1,7 @@
+
+#ifndef RIPPLE_SQLITEDATABASE_H
+#define RIPPLE_SQLITEDATABASE_H
+
#include "database.h"
#include
@@ -112,4 +116,7 @@ public:
std::string getError(int);
};
+#endif
+
// vim:ts=4
+
diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp
index fe0664624..d4dee58a8 100644
--- a/src/cpp/ripple/Application.cpp
+++ b/src/cpp/ripple/Application.cpp
@@ -52,7 +52,7 @@ Application::Application() :
mTempNodeCache("NodeCache", 16384, 90), mHashedObjectStore(16384, 300), mSLECache("LedgerEntryCache", 4096, 120),
mSNTPClient(mAuxService), mJobQueue(mIOService), mFeeTrack(),
- mFeeVote(10, 50 * SYSTEM_CURRENCY_PARTS, 12.5 * SYSTEM_CURRENCY_PARTS),
+ mFeeVote (IFeeVote::New (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),
@@ -407,6 +407,7 @@ void Application::sweep()
Application::~Application()
{
+ delete mFeeVote;
delete mTxnDB;
delete mLedgerDB;
delete mWalletDB;
diff --git a/src/cpp/ripple/Application.h b/src/cpp/ripple/Application.h
index e05126e59..a4b76e43a 100644
--- a/src/cpp/ripple/Application.h
+++ b/src/cpp/ripple/Application.h
@@ -29,6 +29,10 @@
#include "TransactionQueue.h"
#include "OrderBookDB.h"
+// VFALCO: TODO, Fix forward declares required for header dependency loops
+class IFeatureTable;
+class IFeeVote;
+
class RPCDoor;
class PeerDoor;
typedef TaggedCache< uint256, std::vector, UptimeTimerAdapter> NodeCache;
@@ -74,7 +78,7 @@ class Application
LoadFeeTrack mFeeTrack;
TXQueue mTxnQueue;
OrderBookDB mOrderBookDB;
- FeeVote mFeeVote;
+ IFeeVote* mFeeVote;
FeatureTable mFeatureTable;
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
@@ -133,7 +137,7 @@ public:
PeerDoor& getPeerDoor() { return *mPeerDoor; }
OrderBookDB& getOrderBookDB() { return mOrderBookDB; }
SLECache& getSLECache() { return mSLECache; }
- FeeVote& getFeeVote() { return mFeeVote; }
+ IFeeVote& getFeeVote() { return *mFeeVote; }
FeatureTable& getFeatureTable() { return mFeatureTable; }
diff --git a/src/cpp/ripple/FeatureTable.cpp b/src/cpp/ripple/FeatureTable.cpp
index e76e7cb15..d4a725f64 100644
--- a/src/cpp/ripple/FeatureTable.cpp
+++ b/src/cpp/ripple/FeatureTable.cpp
@@ -363,87 +363,4 @@ public:
}
};
-void FeeVote::doValidation(Ledger::ref lastClosedLedger, STObject& validation)
-{
- if (lastClosedLedger->getBaseFee() != mTargetBaseFee)
- {
- WriteLog (lsINFO, FeatureTable) << "Voting for base fee of " << mTargetBaseFee;
- validation.setFieldU64(sfBaseFee, mTargetBaseFee);
- }
-
- if (lastClosedLedger->getReserve(0) != mTargetReserveBase)
- {
- WriteLog (lsINFO, FeatureTable) << "Voting for base resrve of " << mTargetReserveBase;
- validation.setFieldU32(sfReserveBase, mTargetReserveBase);
- }
-
- if (lastClosedLedger->getReserveInc() != mTargetReserveIncrement)
- {
- WriteLog (lsINFO, FeatureTable) << "Voting for reserve increment of " << mTargetReserveIncrement;
- validation.setFieldU32(sfReserveIncrement, mTargetReserveIncrement);
- }
-}
-
-void FeeVote::doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition)
-{
- // LCL must be flag ledger
- assert((lastClosedLedger->getLedgerSeq() % 256) == 0);
-
- VotableInteger baseFeeVote(lastClosedLedger->getBaseFee(), mTargetBaseFee);
- VotableInteger baseReserveVote(lastClosedLedger->getReserve(0), mTargetReserveBase);
- VotableInteger incReserveVote(lastClosedLedger->getReserveInc(), mTargetReserveIncrement);
-
- // get validations for ledger before flag
- ValidationSet set = theApp->getValidations().getValidations(lastClosedLedger->getParentHash());
- BOOST_FOREACH(ValidationSet::value_type& value, set)
- {
- SerializedValidation& val = *value.second;
- if (val.isTrusted())
- {
- if (val.isFieldPresent(sfBaseFee))
- baseFeeVote.addVote(val.getFieldU64(sfBaseFee));
- else
- baseFeeVote.noVote();
- if (val.isFieldPresent(sfReserveBase))
- baseReserveVote.addVote(val.getFieldU32(sfReserveBase));
- else
- baseReserveVote.noVote();
- if (val.isFieldPresent(sfReserveIncrement))
- incReserveVote.addVote(val.getFieldU32(sfReserveIncrement));
- else
- incReserveVote.noVote();
- }
- }
-
- // choose our positions
- uint64 baseFee = baseFeeVote.getVotes();
- uint32 baseReserve = baseReserveVote.getVotes();
- uint32 incReserve = incReserveVote.getVotes();
-
- // add transactions to our position
- if ((baseFee != lastClosedLedger->getBaseFee()) ||
- (baseReserve != lastClosedLedger->getReserve(0)) ||
- (incReserve != lastClosedLedger->getReserveInc()))
- {
- WriteLog (lsWARNING, FeatureTable) << "We are voting for a fee change: " << baseFee << "/" << baseReserve << "/" << incReserve;
- SerializedTransaction trans(ttFEE);
- trans.setFieldAccount(sfAccount, uint160());
- trans.setFieldU64(sfBaseFee, baseFee);
- trans.setFieldU32(sfReferenceFeeUnits, 10);
- trans.setFieldU32(sfReserveBase, baseReserve);
- trans.setFieldU32(sfReserveIncrement, incReserve);
- uint256 txID = trans.getTransactionID();
- WriteLog (lsWARNING, FeatureTable) << "Vote: " << txID;
-
- Serializer s;
- trans.add(s, true);
-
- SHAMapItem::pointer tItem = boost::make_shared(txID, s.peekData());
- if (!initialPosition->addGiveItem(tItem, true, false))
- {
- WriteLog (lsWARNING, FeatureTable) << "Ledger already had fee change";
- }
- }
-}
-
// vim:ts=4
diff --git a/src/cpp/ripple/FeatureTable.h b/src/cpp/ripple/FeatureTable.h
index 9579f4019..634427fda 100644
--- a/src/cpp/ripple/FeatureTable.h
+++ b/src/cpp/ripple/FeatureTable.h
@@ -81,27 +81,4 @@ public:
void doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition);
};
-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)
- { ; }
-
- // add our wishes to our validation
- void doValidation(Ledger::ref lastClosedLedger, STObject& baseValidation);
-
- // vote on the fee we want
- void doVoting(Ledger::ref lastClosedLedger, SHAMap::ref initialPosition);
-};
-
#endif
diff --git a/src/cpp/ripple/ripple_FeeVote.cpp b/src/cpp/ripple/ripple_FeeVote.cpp
new file mode 100644
index 000000000..5a5c9b6c3
--- /dev/null
+++ b/src/cpp/ripple/ripple_FeeVote.cpp
@@ -0,0 +1,136 @@
+
+class FeatureTable;
+
+//------------------------------------------------------------------------------
+
+class FeeVote : public IFeeVote
+{
+public:
+ FeeVote (uint64 targetBaseFee, uint32 targetReserveBase, uint32 targetReserveIncrement)
+ : mTargetBaseFee (targetBaseFee)
+ , mTargetReserveBase (targetReserveBase)
+ , mTargetReserveIncrement (targetReserveIncrement)
+ {
+ }
+
+ //--------------------------------------------------------------------------
+
+ void doValidation (Ledger::ref lastClosedLedger, STObject& baseValidation)
+ {
+ if (lastClosedLedger->getBaseFee() != mTargetBaseFee)
+ {
+ WriteLog (lsINFO, FeatureTable) << "Voting for base fee of " << mTargetBaseFee;
+ baseValidation.setFieldU64(sfBaseFee, mTargetBaseFee);
+ }
+
+ if (lastClosedLedger->getReserve(0) != mTargetReserveBase)
+ {
+ WriteLog (lsINFO, FeatureTable) << "Voting for base resrve of " << mTargetReserveBase;
+ baseValidation.setFieldU32(sfReserveBase, mTargetReserveBase);
+ }
+
+ if (lastClosedLedger->getReserveInc() != mTargetReserveIncrement)
+ {
+ WriteLog (lsINFO, FeatureTable) << "Voting for reserve increment of " << mTargetReserveIncrement;
+ baseValidation.setFieldU32(sfReserveIncrement, mTargetReserveIncrement);
+ }
+ }
+
+ //--------------------------------------------------------------------------
+
+ void doVoting (Ledger::ref lastClosedLedger, SHAMap::ref initialPosition)
+ {
+ // LCL must be flag ledger
+ assert((lastClosedLedger->getLedgerSeq() % 256) == 0);
+
+ VotableInteger baseFeeVote(lastClosedLedger->getBaseFee(), mTargetBaseFee);
+ VotableInteger baseReserveVote(lastClosedLedger->getReserve(0), mTargetReserveBase);
+ VotableInteger incReserveVote(lastClosedLedger->getReserveInc(), mTargetReserveIncrement);
+
+ // get validations for ledger before flag
+ ValidationSet set = theApp->getValidations().getValidations(lastClosedLedger->getParentHash());
+ BOOST_FOREACH(ValidationSet::value_type const& value, set)
+ {
+ SerializedValidation const& val = *value.second;
+
+ if (val.isTrusted())
+ {
+ if (val.isFieldPresent(sfBaseFee))
+ {
+ baseFeeVote.addVote(val.getFieldU64(sfBaseFee));
+ }
+ else
+ {
+ baseFeeVote.noVote();
+ }
+
+ if (val.isFieldPresent(sfReserveBase))
+ {
+ baseReserveVote.addVote(val.getFieldU32(sfReserveBase));
+ }
+ else
+ {
+ baseReserveVote.noVote();
+ }
+
+ if (val.isFieldPresent(sfReserveIncrement))
+ {
+ incReserveVote.addVote(val.getFieldU32(sfReserveIncrement));
+ }
+ else
+ {
+ incReserveVote.noVote();
+ }
+ }
+ }
+
+ // choose our positions
+ uint64 baseFee = baseFeeVote.getVotes();
+ uint32 baseReserve = baseReserveVote.getVotes();
+ uint32 incReserve = incReserveVote.getVotes();
+
+ // add transactions to our position
+ if ((baseFee != lastClosedLedger->getBaseFee()) ||
+ (baseReserve != lastClosedLedger->getReserve(0)) ||
+ (incReserve != lastClosedLedger->getReserveInc()))
+ {
+ WriteLog (lsWARNING, FeatureTable) << "We are voting for a fee change: " << baseFee << "/" << baseReserve << "/" << incReserve;
+
+ SerializedTransaction trans(ttFEE);
+ trans.setFieldAccount(sfAccount, uint160());
+ trans.setFieldU64(sfBaseFee, baseFee);
+ trans.setFieldU32(sfReferenceFeeUnits, 10);
+ trans.setFieldU32(sfReserveBase, baseReserve);
+ trans.setFieldU32(sfReserveIncrement, incReserve);
+
+ uint256 txID = trans.getTransactionID();
+
+ WriteLog (lsWARNING, FeatureTable) << "Vote: " << txID;
+
+ Serializer s;
+ trans.add(s, true);
+
+ SHAMapItem::pointer tItem = boost::make_shared(txID, s.peekData());
+ if (!initialPosition->addGiveItem(tItem, true, false))
+ {
+ WriteLog (lsWARNING, FeatureTable) << "Ledger already had fee change";
+ }
+ }
+ }
+
+private:
+ uint64 mTargetBaseFee;
+ uint32 mTargetReserveBase;
+ uint32 mTargetReserveIncrement;
+};
+
+//------------------------------------------------------------------------------
+
+IFeeVote* IFeeVote::New (uint64 targetBaseFee,
+ uint32 targetReserveBase,
+ uint32 targetReserveIncrement)
+{
+ return new FeeVote (targetBaseFee, targetReserveBase, targetReserveIncrement);
+}
+
+// vim:ts=4
diff --git a/src/cpp/ripple/ripple_IFeatures.h b/src/cpp/ripple/ripple_IFeatures.h
new file mode 100644
index 000000000..a8d41ea07
--- /dev/null
+++ b/src/cpp/ripple/ripple_IFeatures.h
@@ -0,0 +1,21 @@
+#ifndef RIPPLE_IFEATURES_H
+#define RIPPLE_IFEATURES_H
+
+/** Feature table interface.
+
+ The feature table stores the list of enabled and potential features.
+ Individuals features are voted on by validators during the consensus
+ process.
+*/
+class IFeatureTable
+{
+public:
+ static IFeatureTable* New (uint32 majorityTime, int majorityFraction);
+
+ virtual ~IFeatureTable () { }
+
+ virtual void doValidation (Ledger::ref lastClosedLedger, STObject& baseValidation) = 0;
+ virtual void doVoting (Ledger::ref lastClosedLedger, SHAMap::ref initialPosition) = 0;
+};
+
+#endif
diff --git a/src/cpp/ripple/ripple_IFeeVote.h b/src/cpp/ripple/ripple_IFeeVote.h
new file mode 100644
index 000000000..3bfe94e13
--- /dev/null
+++ b/src/cpp/ripple/ripple_IFeeVote.h
@@ -0,0 +1,38 @@
+#ifndef RIPPLE_IFEEVOTE_H
+#define RIPPLE_IFEEVOTE_H
+
+/** Manager to process fee votes.
+*/
+class IFeeVote
+{
+public:
+ /** Create a new fee vote manager.
+
+ @param targetBaseFee
+ @param targetReserveBase
+ @param targetReserveIncrement
+ */
+ static IFeeVote* New (uint64 targetBaseFee,
+ uint32 targetReserveBase,
+ uint32 targetReserveIncrement);
+
+ virtual ~IFeeVote () { }
+
+ /** Add local fee preference to validation.
+
+ @param lastClosedLedger
+ @param baseValidation
+ */
+ virtual void doValidation (Ledger::ref lastClosedLedger,
+ STObject& baseValidation) = 0;
+
+ /** Cast our local vote on the fee.
+
+ @param lastClosedLedger
+ @param initialPosition
+ */
+ virtual void doVoting (Ledger::ref lastClosedLedger,
+ SHAMap::ref initialPosition) = 0;
+};
+
+#endif