diff --git a/modules/ripple_main/ripple_main.cpp b/modules/ripple_main/ripple_main.cpp
index cdba2c6a0f..bc9b95cd36 100644
--- a/modules/ripple_main/ripple_main.cpp
+++ b/modules/ripple_main/ripple_main.cpp
@@ -67,10 +67,10 @@
//------------------------------------------------------------------------------
// VFALCO: TODO, prepare a unity header for LevelDB
-#ifdef USE_LEVELDB
#include "leveldb/cache.h"
#include "leveldb/filter_policy.h"
-#endif
+#include "leveldb/db.h"
+#include "leveldb/write_batch.h"
//------------------------------------------------------------------------------
@@ -93,6 +93,7 @@
#include "src/cpp/ripple/Ledger.h"
#include "src/cpp/ripple/SerializedValidation.h"
#include "src/cpp/database/SqliteDatabase.h"
+#include "src/cpp/ripple/LoadManager.h"
//------------------------------------------------------------------------------
//
@@ -105,6 +106,9 @@
#include "src/cpp/ripple/ripple_ProofOfWork.h"
#include "src/cpp/ripple/ripple_Job.h"
#include "src/cpp/ripple/ripple_JobQueue.h"
+#include "src/cpp/ripple/ripple_UptimeTimerAdapter.h"
+#include "src/cpp/ripple/ripple_HashedObject.h"
+#include "src/cpp/ripple/ripple_HashedObjectStore.h"
#include "src/cpp/ripple/ripple_IFeatures.h"
#include "src/cpp/ripple/ripple_IFeeVote.h"
@@ -139,7 +143,6 @@
#include "src/cpp/ripple/ChangeTransactor.h"
#include "src/cpp/ripple/HTTPRequest.h"
#include "src/cpp/ripple/HashPrefixes.h"
-#include "src/cpp/ripple/HashedObject.h"
#include "src/cpp/ripple/HttpsClient.h"
#include "src/cpp/ripple/Ledger.h"
#include "src/cpp/ripple/LedgerAcquire.h"
@@ -149,7 +152,6 @@
#include "src/cpp/ripple/LedgerMaster.h"
#include "src/cpp/ripple/LedgerProposal.h"
#include "src/cpp/ripple/LedgerTiming.h"
-#include "src/cpp/ripple/LoadManager.h"
#include "src/cpp/ripple/NetworkOPs.h"
#include "src/cpp/ripple/NicknameState.h"
#include "src/cpp/ripple/Offer.h"
@@ -224,7 +226,6 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ChangeTransactor.cpp" // no log
#include "src/cpp/ripple/Contract.cpp" // no log
#include "src/cpp/ripple/DBInit.cpp"
-#include "src/cpp/ripple/HashedObject.cpp"
#include "src/cpp/ripple/HTTPRequest.cpp"
#include "src/cpp/ripple/HttpsClient.cpp"
#include "src/cpp/ripple/Interpreter.cpp" // no log
@@ -288,10 +289,12 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
// Refactored sources
-#include "src/cpp/ripple/ripple_Config.cpp" // no log
+#include "src/cpp/ripple/ripple_Config.cpp"
#include "src/cpp/ripple/ripple_DatabaseCon.cpp"
#include "src/cpp/ripple/ripple_Features.cpp"
#include "src/cpp/ripple/ripple_FeeVote.cpp"
+#include "src/cpp/ripple/ripple_HashedObject.cpp"
+#include "src/cpp/ripple/ripple_HashedObjectStore.cpp"
#include "src/cpp/ripple/ripple_HashRouter.cpp"
#include "src/cpp/ripple/ripple_Job.cpp"
#include "src/cpp/ripple/ripple_JobQueue.cpp"
diff --git a/newcoin.vcxproj b/newcoin.vcxproj
index 84ad582e9f..190b15b75e 100644
--- a/newcoin.vcxproj
+++ b/newcoin.vcxproj
@@ -758,6 +758,18 @@
true
true
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
true
true
@@ -776,12 +788,6 @@
true
true
-
- true
- true
- true
- true
-
true
true
@@ -1645,9 +1651,10 @@
+
+
-
@@ -1692,6 +1699,7 @@
+
diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters
index a521911fbd..bfb5b952e4 100644
--- a/newcoin.vcxproj.filters
+++ b/newcoin.vcxproj.filters
@@ -462,9 +462,6 @@
1. Modules\ripple_main\_unfactored\contracts
-
- 1. Modules\ripple_main\_unfactored\types
-
1. Modules\ripple_main\_unfactored\types
@@ -813,6 +810,12 @@
1. Modules\ripple_main\refactored
+
+ 1. Modules\ripple_main\refactored
+
+
+ 1. Modules\ripple_main\refactored
+
@@ -1130,9 +1133,6 @@
1. Modules\ripple_main\_unfactored\contracts
-
- 1. Modules\ripple_main\_unfactored\types
-
1. Modules\ripple_main\_unfactored\types
@@ -1511,6 +1511,15 @@
1. Modules\ripple_main\refactored
+
+ 1. Modules\ripple_main\refactored
+
+
+ 1. Modules\ripple_main\refactored
+
+
+ 1. Modules\ripple_main\refactored
+
diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp
index 04eaeb41f8..213f15ed79 100644
--- a/src/cpp/ripple/Application.cpp
+++ b/src/cpp/ripple/Application.cpp
@@ -1,23 +1,4 @@
-/*
-#include "Application.h"
-
-#include "leveldb/cache.h"
-#include "leveldb/filter_policy.h"
-
-#include "AcceptedLedger.h"
-#include "PeerDoor.h"
-#include "RPCDoor.h"
-
-#include "../database/SqliteDatabase.h"
-
-#include
-
-#include
-#include
-#include
-*/
-
// VFALCO: TODO Replace these with beast "unsigned long long" generators
#define SYSTEM_CURRENCY_GIFT 1000ull
#define SYSTEM_CURRENCY_USERS 100000000ull
@@ -58,10 +39,7 @@ Application::Application ()
, mNetNodeDB (NULL)
, mPathFindDB (NULL)
, mHashNodeDB (NULL)
- // VFALCO: TODO eliminate USE_LEVELDB macro
-#ifdef USE_LEVELDB
, mHashNodeLDB (NULL)
-#endif
, mPeerDoor (NULL)
, mRPCDoor (NULL)
, mWSPublicDoor (NULL)
diff --git a/src/cpp/ripple/Application.h b/src/cpp/ripple/Application.h
index 5ab15c2b3f..0337c0327b 100644
--- a/src/cpp/ripple/Application.h
+++ b/src/cpp/ripple/Application.h
@@ -33,8 +33,9 @@ class IPeers;
class RPCDoor;
class PeerDoor;
-typedef TaggedCache< uint256, std::vector, UptimeTimerAdapter> NodeCache;
-typedef TaggedCache< uint256, SLE, UptimeTimerAdapter> SLECache;
+
+typedef TaggedCache , UptimeTimerAdapter> NodeCache;
+typedef TaggedCache SLECache;
class Application
{
@@ -92,7 +93,11 @@ public:
void sweep();
private:
- boost::asio::io_service mIOService;
+ void updateTables (bool);
+ void startNewLedger ();
+ bool loadOldLedger (const std::string&);
+
+ boost::asio::io_service mIOService;
boost::asio::io_service mAuxService;
boost::asio::io_service::work mIOWork;
boost::asio::io_service::work mAuxWork;
@@ -112,7 +117,7 @@ private:
LoadManager mLoadMgr;
TXQueue mTxnQueue;
OrderBookDB mOrderBookDB;
-
+
// VFALCO: Clean stuff
beast::ScopedPointer mFeatures;
beast::ScopedPointer mFeeVote;
@@ -140,10 +145,6 @@ private:
boost::recursive_mutex mPeerMapLock;
volatile bool mShutdown;
-
- void updateTables(bool);
- void startNewLedger();
- bool loadOldLedger(const std::string&);
};
extern Application* theApp;
diff --git a/src/cpp/ripple/HashedObject.h b/src/cpp/ripple/HashedObject.h
deleted file mode 100644
index 31e31c3c16..0000000000
--- a/src/cpp/ripple/HashedObject.h
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef __HASHEDOBJECT__
-#define __HASHEDOBJECT__
-
-#include
-
-#include
-#include
-
-// VFALCO: TODO, Move this to someplace sensible!!
-// Adapter to furnish uptime information to KeyCache via UptimeTimer singleton
-struct UptimeTimerAdapter
-{
- inline static int getElapsedSeconds ()
- {
- return UptimeTimer::getInstance().getElapsedSeconds ();
- }
-};
-
-
-
-DEFINE_INSTANCE(HashedObject);
-
-class Job;
-
-enum HashedObjectType
-{
- hotUNKNOWN = 0,
- hotLEDGER = 1,
- hotTRANSACTION = 2,
- hotACCOUNT_NODE = 3,
- hotTRANSACTION_NODE = 4
-};
-
-class HashedObject : private IS_INSTANCE(HashedObject)
-{
-public:
- typedef boost::shared_ptr pointer;
-
- HashedObjectType mType;
- uint256 mHash;
- uint32 mLedgerIndex;
- std::vector mData;
-
- HashedObject(HashedObjectType type, uint32 index, const std::vector& data, const uint256& hash) :
- mType(type), mHash(hash), mLedgerIndex(index), mData(data) { ; }
-
- HashedObject(HashedObjectType type, uint32 index, const unsigned char *data, int dlen, const uint256& hash) :
- mType(type), mHash(hash), mLedgerIndex(index), mData(data, data + dlen) { ; }
-
- const std::vector& getData() const { return mData; }
- const uint256& getHash() const { return mHash; }
- HashedObjectType getType() const { return mType; }
- uint32 getIndex() const { return mLedgerIndex; }
-};
-
-class HashedObjectStore
-{
-public:
- HashedObjectStore(int cacheSize, int cacheAge);
-
- bool isLevelDB() { return mLevelDB; }
-
- float getCacheHitRate() { return mCache.getHitRate(); }
-
- bool store(HashedObjectType type, uint32 index, const std::vector& data,
- const uint256& hash)
- {
- if (mLevelDB)
- return storeLevelDB(type, index, data, hash);
- return storeSQLite(type, index, data, hash);
- }
-
- HashedObject::pointer retrieve(const uint256& hash)
- {
- if (mLevelDB)
- return retrieveLevelDB(hash);
- return retrieveSQLite(hash);
- }
-
- bool storeSQLite(HashedObjectType type, uint32 index, const std::vector& data,
- const uint256& hash);
- HashedObject::pointer retrieveSQLite(const uint256& hash);
- void bulkWriteSQLite(Job&);
-
- bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector& data,
- const uint256& hash);
- HashedObject::pointer retrieveLevelDB(const uint256& hash);
- void bulkWriteLevelDB(Job&);
-
-
- void waitWrite();
- void tune(int size, int age);
- void sweep() { mCache.sweep(); mNegativeCache.sweep(); }
- int getWriteLoad();
-
- int import(const std::string& fileName);
-
-private:
- TaggedCache mCache;
- KeyCache mNegativeCache;
-
- boost::mutex mWriteMutex;
- boost::condition_variable mWriteCondition;
- int mWriteGeneration;
- int mWriteLoad;
-
- std::vector< boost::shared_ptr > mWriteSet;
- bool mWritePending;
- bool mLevelDB;
- bool mEphemeralDB;
-};
-
-#endif
-// vim:ts=4
diff --git a/src/cpp/ripple/HttpsClient.cpp b/src/cpp/ripple/HttpsClient.cpp
index d772f076a3..86b56adff9 100644
--- a/src/cpp/ripple/HttpsClient.cpp
+++ b/src/cpp/ripple/HttpsClient.cpp
@@ -2,35 +2,20 @@
// Fetch a web page via https.
//
-#include "HttpsClient.h"
-
-#include
-#include
-#include
-#include
-#include
-
-#define CLIENT_MAX_HEADER (32*1024)
-
SETUP_LOG (HttpsClient)
-using namespace boost::system;
-using namespace boost::asio;
-
-HttpsClient::HttpsClient(
- boost::asio::io_service& io_service,
- const unsigned short port,
- std::size_t responseMax
- ) :
- mSocket(io_service, theConfig.SSL_CONTEXT),
- mResolver(io_service),
- mHeader(CLIENT_MAX_HEADER),
- mPort(port),
- mResponseMax(responseMax),
- mDeadline(io_service)
+HttpsClient::HttpsClient (boost::asio::io_service& io_service,
+ const unsigned short port,
+ std::size_t responseMax)
+ : mSocket (io_service, theConfig.SSL_CONTEXT)
+ , mResolver (io_service)
+ , mHeader (maxClientHeaderBytes)
+ , mPort (port)
+ , mResponseMax (responseMax)
+ , mDeadline (io_service)
{
if (!theConfig.SSL_VERIFY)
- mSocket.SSLSocket().set_verify_mode(boost::asio::ssl::verify_none);
+ mSocket.SSLSocket().set_verify_mode (boost::asio::ssl::verify_none);
}
void HttpsClient::makeGet(const std::string& strPath, boost::asio::streambuf& sb, const std::string& strHost)
@@ -82,8 +67,11 @@ void HttpsClient::httpsNext()
{
WriteLog (lsTRACE, HttpsClient) << "Fetch: " << mDeqSites[0];
- boost::shared_ptr query(new boost::asio::ip::tcp::resolver::query(mDeqSites[0], boost::lexical_cast(mPort),
- ip::resolver_query_base::numeric_service));
+ boost::shared_ptr query (
+ new boost::asio::ip::tcp::resolver::query (
+ mDeqSites[0],
+ boost::lexical_cast (mPort),
+ boost::asio::ip::resolver_query_base::numeric_service));
mQuery = query;
mDeadline.expires_from_now(mTimeout, mShutdown);
@@ -477,7 +465,7 @@ void HttpsClient::sendSMS(boost::asio::io_service& io_service, const std::string
if (iPort < 0)
iPort = bSSL ? 443 : 80;
- boost::shared_ptr client(new HttpsClient(io_service, iPort, CLIENT_MAX_HEADER));
+ boost::shared_ptr client(new HttpsClient(io_service, iPort, maxClientHeaderBytes));
client->httpsGet(bSSL, deqSites, strURI, boost::posix_time::seconds(SMS_TIMEOUT),
BIND_TYPE(&responseSMS, P_1, P_2, P_3));
diff --git a/src/cpp/ripple/HttpsClient.h b/src/cpp/ripple/HttpsClient.h
index 41c22c2988..1ecd743cb3 100644
--- a/src/cpp/ripple/HttpsClient.h
+++ b/src/cpp/ripple/HttpsClient.h
@@ -18,54 +18,7 @@
class HttpsClient : public boost::enable_shared_from_this
{
-private:
- typedef boost::shared_ptr pointer;
-
- bool mSSL;
- AutoSocket mSocket;
- boost::asio::ip::tcp::resolver mResolver;
- boost::shared_ptr mQuery;
- boost::asio::streambuf mRequest;
- boost::asio::streambuf mHeader;
- boost::asio::streambuf mResponse;
- std::string mBody;
- const unsigned short mPort;
- int mResponseMax;
- int mStatus;
- FUNCTION_TYPE mBuild;
- FUNCTION_TYPE mComplete;
-
- boost::asio::deadline_timer mDeadline;
-
- // If not success, we are shutting down.
- boost::system::error_code mShutdown;
-
- std::deque mDeqSites;
- boost::posix_time::time_duration mTimeout;
-
- void handleDeadline(const boost::system::error_code& ecResult);
-
- void handleResolve(const boost::system::error_code& ecResult, boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
- void handleConnect(const boost::system::error_code& ecResult);
-
- void handleRequest(const boost::system::error_code& ecResult);
-
- void handleWrite(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
-
- void handleHeader(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
-
- void handleData(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
-
- void handleShutdown(const boost::system::error_code& ecResult);
-
- void httpsNext();
-
- void invokeComplete(const boost::system::error_code& ecResult, int iStatus = 0, const std::string& strData = "");
-
- void makeGet(const std::string& strPath, boost::asio::streambuf& sb, const std::string& strHost);
public:
-
HttpsClient(
boost::asio::io_service& io_service,
const unsigned short port,
@@ -117,6 +70,56 @@ public:
FUNCTION_TYPE complete);
static void sendSMS(boost::asio::io_service& io_service, const std::string& strText);
+
+private:
+ static const int maxClientHeaderBytes = 32 * 1024;
+
+ typedef boost::shared_ptr pointer;
+
+ bool mSSL;
+ AutoSocket mSocket;
+ boost::asio::ip::tcp::resolver mResolver;
+ boost::shared_ptr mQuery;
+ boost::asio::streambuf mRequest;
+ boost::asio::streambuf mHeader;
+ boost::asio::streambuf mResponse;
+ std::string mBody;
+ const unsigned short mPort;
+ int mResponseMax;
+ int mStatus;
+ FUNCTION_TYPE mBuild;
+ FUNCTION_TYPE mComplete;
+
+ boost::asio::deadline_timer mDeadline;
+
+ // If not success, we are shutting down.
+ boost::system::error_code mShutdown;
+
+ std::deque mDeqSites;
+ boost::posix_time::time_duration mTimeout;
+
+ void handleDeadline(const boost::system::error_code& ecResult);
+
+ void handleResolve(const boost::system::error_code& ecResult, boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+ void handleConnect(const boost::system::error_code& ecResult);
+
+ void handleRequest(const boost::system::error_code& ecResult);
+
+ void handleWrite(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
+
+ void handleHeader(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
+
+ void handleData(const boost::system::error_code& ecResult, std::size_t bytes_transferred);
+
+ void handleShutdown(const boost::system::error_code& ecResult);
+
+ void httpsNext();
+
+ void invokeComplete(const boost::system::error_code& ecResult, int iStatus = 0, const std::string& strData = "");
+
+ void makeGet(const std::string& strPath, boost::asio::streambuf& sb, const std::string& strHost);
};
+
#endif
// vim:ts=4
diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h
index a97763a528..df7e5adc47 100644
--- a/src/cpp/ripple/Ledger.h
+++ b/src/cpp/ripple/Ledger.h
@@ -1,13 +1,9 @@
-#ifndef __LEDGER__
-#define __LEDGER__
+#ifndef RIPPLE_LEDGER_H
+#define RIPPLE_LEDGER_H
-#include