diff --git a/modules/ripple_basics/utility/ripple_InstanceCounter.h b/modules/ripple_basics/utility/ripple_InstanceCounter.h index bcdcebdde..f1275320b 100644 --- a/modules/ripple_basics/utility/ripple_InstanceCounter.h +++ b/modules/ripple_basics/utility/ripple_InstanceCounter.h @@ -1,7 +1,7 @@ #ifndef RIPPLE_INSTANCECOUNTER_H #define RIPPLE_INSTANCECOUNTER_H -// VFALCO TODO Clean up this junk, remove the macros, replace +// VFALCO TODO Clean this up, remove the macros, replace // with a robust leak checker when we have atomics. // @@ -38,7 +38,7 @@ protected: public: typedef std::pair InstanceCount; - InstanceType(const char *n) : mInstances(0), mName(n) + explicit InstanceType (const char *n) : mInstances(0), mName(n) { mNextInstance = sHeadInstance; sHeadInstance = this; @@ -65,7 +65,7 @@ public: { if (sMultiThreaded) { - // VFALCO NOTE Junk that will go away with atomics + // VFALCO NOTE This will go away with atomics mLock.lock(); ++mInstances; mLock.unlock(); diff --git a/modules/ripple_basics/utility/ripple_RandomNumbers.cpp b/modules/ripple_basics/utility/ripple_RandomNumbers.cpp index 1336434ac..b2673617e 100644 --- a/modules/ripple_basics/utility/ripple_RandomNumbers.cpp +++ b/modules/ripple_basics/utility/ripple_RandomNumbers.cpp @@ -160,7 +160,7 @@ bool RandomNumbers::platformAddEntropy () void RandomNumbers::platformAddPerformanceMonitorEntropy () { - // VFALCO This is how we simulate local functions + // VFALCO TODO Remove all this fancy stuff struct { int64 operator() () const diff --git a/modules/ripple_basics/utility/ripple_Sustain.h b/modules/ripple_basics/utility/ripple_Sustain.h index bbd612a85..be254a73e 100644 --- a/modules/ripple_basics/utility/ripple_Sustain.h +++ b/modules/ripple_basics/utility/ripple_Sustain.h @@ -19,7 +19,10 @@ #ifndef RIPPLE_SUSTAIN_H #define RIPPLE_SUSTAIN_H -// VFALCO TODO figure out what the heck this is?? +// "Sustain" is a system for a buddy process that monitors the main process +// and relaunches it on a fault. +// +// VFALCO TODO Rename this and put it in a class. extern bool HaveSustain(); extern std::string StopSustain(); extern std::string DoSustain(); diff --git a/modules/ripple_data/protocol/ripple_LedgerFormat.cpp b/modules/ripple_data/protocol/ripple_LedgerFormat.cpp index e46a08242..cc799e6ec 100644 --- a/modules/ripple_data/protocol/ripple_LedgerFormat.cpp +++ b/modules/ripple_data/protocol/ripple_LedgerFormat.cpp @@ -3,8 +3,6 @@ std::map LedgerEntryFormat::byType; std::map LedgerEntryFormat::byName; -// VFALCO TODO surely we can think of a better way than macros? - #define LEF_BASE \ << SOElement(sfLedgerIndex, SOE_OPTIONAL) \ << SOElement(sfLedgerEntryType, SOE_REQUIRED) \ diff --git a/modules/ripple_data/protocol/ripple_SerializedTypes.h b/modules/ripple_data/protocol/ripple_SerializedTypes.h index ae5aafec8..a55ecc074 100644 --- a/modules/ripple_data/protocol/ripple_SerializedTypes.h +++ b/modules/ripple_data/protocol/ripple_SerializedTypes.h @@ -30,7 +30,7 @@ static const uint160 u160_zero(0), u160_one(1); static inline const uint160& get_u160_zero() { return u160_zero; } static inline const uint160& get_u160_one() { return u160_one; } -// VFALCO TODO replace these with language constructs, gah! +// VFALCO TODO replace these with language constructs #define CURRENCY_XRP get_u160_zero() #define CURRENCY_ONE get_u160_one() // Used as a place holder. #define CURRENCY_BAD uint160(0x5852500000000000) // Do not allow XRP as an IOU currency. diff --git a/src/cpp/database/SqliteDatabase.cpp b/src/cpp/database/SqliteDatabase.cpp index e8e7f8e97..6bfc28b98 100644 --- a/src/cpp/database/SqliteDatabase.cpp +++ b/src/cpp/database/SqliteDatabase.cpp @@ -117,20 +117,6 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok) return true; } -// tells you how many rows were changed by an update or insert -int SqliteDatabase::getNumRowsAffected() -{ - // TODO: SqliteDatabase::getNumRowsAffected() - return(0); -} - -// VFALCO TODO This must be fixed!!! return value needs to be int64 -// -int SqliteDatabase::getLastInsertID() -{ - return(sqlite3_last_insert_rowid(mConnection)); -} - // returns false if there are no results bool SqliteDatabase::startIterRows(bool finalize) { diff --git a/src/cpp/database/SqliteDatabase.h b/src/cpp/database/SqliteDatabase.h index f219f17b3..55b9d679d 100644 --- a/src/cpp/database/SqliteDatabase.h +++ b/src/cpp/database/SqliteDatabase.h @@ -27,7 +27,6 @@ public: // tells you how many rows were changed by an update or insert int getNumRowsAffected(); - int getLastInsertID(); // returns false if there are no results bool startIterRows(bool finalize); diff --git a/src/cpp/database/database.h b/src/cpp/database/database.h index 4bfb1c668..f8cdbece7 100644 --- a/src/cpp/database/database.h +++ b/src/cpp/database/database.h @@ -43,10 +43,6 @@ public: return executeSQL(strSql.c_str(), fail_okay); } - // tells you how many rows were changed by an update or insert - virtual int getNumRowsAffected()=0; - virtual int getLastInsertID()=0; - // returns false if there are no results virtual bool startIterRows(bool finalize = true)=0; virtual void endIterRows()=0; diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 19fb28ef4..8b415af21 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -971,16 +971,21 @@ void NetworkOPs::mapComplete(uint256 const& hash, SHAMap::ref map) mConsensus->mapComplete(hash, map, true); } -void NetworkOPs::endConsensus(bool correctLCL) +void NetworkOPs::endConsensus (bool correctLCL) { uint256 deadLedger = mLedgerMaster->getClosedLedger()->getParentHash(); - std::vector peerList = theApp->getPeers().getPeerVector(); - BOOST_FOREACH(Peer::ref it, peerList) + + std::vector peerList = theApp->getPeers().getPeerVector (); + + BOOST_FOREACH(Peer::ref it, peerList) + { if (it && (it->getClosedLedgerHash() == deadLedger)) { WriteLog (lsTRACE, NetworkOPs) << "Killing obsolete peer status"; it->cycleStatus(); } + } + mConsensus = boost::shared_ptr(); } @@ -990,33 +995,43 @@ void NetworkOPs::consensusViewChange() setMode(omCONNECTED); } -void NetworkOPs::pubServer() +void NetworkOPs::pubServer () { - boost::recursive_mutex::scoped_lock sl(mMonitorLock); + // VFALCO TODO Don't hold the lock across calls to send...make a copy of the + // list into a local array while holding the lock then release the + // lock and call send on everyone. + // + boost::recursive_mutex::scoped_lock sl (mMonitorLock); - if (!mSubServer.empty()) - { - Json::Value jvObj(Json::objectValue); + if (!mSubServer.empty ()) + { + Json::Value jvObj (Json::objectValue); - jvObj["type"] = "serverStatus"; - jvObj["server_status"] = strOperatingMode(); - jvObj["load_base"] = (mLastLoadBase = theApp->getFeeTrack().getLoadBase()); - jvObj["load_factor"] = (mLastLoadFactor = theApp->getFeeTrack().getLoadFactor()); + jvObj ["type"] = "serverStatus"; + jvObj ["server_status"] = strOperatingMode(); + jvObj ["load_base"] = (mLastLoadBase = theApp->getFeeTrack().getLoadBase()); + jvObj ["load_factor"] = (mLastLoadFactor = theApp->getFeeTrack().getLoadFactor()); - NetworkOPs::subMapType::const_iterator it = mSubServer.begin(); - while (it != mSubServer.end()) - { - InfoSub::pointer p = it->second.lock(); - if (p) - { - p->send(jvObj, true); - ++it; - } - else - it = mSubServer.erase(it); - } + NetworkOPs::subMapType::const_iterator it = mSubServer.begin(); - } + while (it != mSubServer.end()) + { + InfoSub::pointer p = it->second.lock(); + + // VFALCO TODO research the possibility of using thread queues and linearizing + // the deletion of subscribers with the sending of JSON data. + if (p) + { + p->send(jvObj, true); + + ++it; + } + else + { + it = mSubServer.erase(it); + } + } + } } void NetworkOPs::setMode(OperatingMode om) @@ -1662,9 +1677,11 @@ bool NetworkOPs::subBook(InfoSub::ref isrListener, const uint160& currencyPays, { BookListeners::pointer listeners = theApp->getOrderBookDB().makeBookListeners(currencyPays, currencyGets, issuerPays, issuerGets); - if (listeners) + + if (listeners) listeners->addSubscriber(isrListener); - return true; + + return true; } bool NetworkOPs::unsubBook(uint64 uSeq, diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index ef8090b72..533664259 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -25,7 +25,22 @@ public: omFULL = 4 // we have the ledger and can even validate }; - typedef boost::unordered_map subMapType; +#if 0 + /** Subscription data interface. + */ + class Subscriber + { + public: + typedef boost::weak_ptr WeakPtr; + + /** Called every time new JSON data is available. + */ + virtual void onSubscriberReceiveJSON (Json::Value const& json) { } + }; + typedef boost::unordered_map subMapType; +#endif + + typedef boost::unordered_map subMapType; public: NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster); diff --git a/src/cpp/ripple/ripple_JobQueue.cpp b/src/cpp/ripple/ripple_JobQueue.cpp index 30073d61a..9eb52ab3f 100644 --- a/src/cpp/ripple/ripple_JobQueue.cpp +++ b/src/cpp/ripple/ripple_JobQueue.cpp @@ -215,10 +215,8 @@ void JobQueue::IOThread(boost::mutex::scoped_lock& sl) // do jobs until asked to stop void JobQueue::threadEntry() { - - // VFALCO TODO Replace this mutex nonsense - // boost::mutex::scoped_lock sl(mJobLock); + while (1) { setCallingThreadName("waiting"); diff --git a/src/cpp/websocket_core.cpp b/src/cpp/websocket_core.cpp index 25f76e584..369149542 100644 --- a/src/cpp/websocket_core.cpp +++ b/src/cpp/websocket_core.cpp @@ -3,8 +3,8 @@ // // VFALCO TODO Fix this right. It's not really needed -// to include this file, its a hack to keep -// __STDC_LIMIT_MACROS from generating redefinition warnings +// to include this file, its a hack to keep +// __STDC_LIMIT_MACROS from generating redefinition warnings #include "websocketpp/src/rng/boost_rng.hpp" // Must come first to prevent compile errors