diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index ca67723927..8d03a82054 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -24,6 +24,7 @@ NetworkOPs::NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedg , mProposing (false) , mValidating (false) , mFeatureBlocked (false) + //, m_netTimer (this) , mNetTimer (io_service) , mLedgerMaster (pLedgerMaster) , mCloseTimeOffset (0) @@ -38,6 +39,12 @@ NetworkOPs::NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedg , mLastLoadBase (256) , mLastLoadFactor (256) { +// m_netTimer.setExpirationRecurring (LEDGER_GRANULARITY / 1000.0); +} + +void NetworkOPs::onDeadlineTimer () +{ +// WriteLog (lsINFO, NetworkOPs) << "NetworkOPs::onDeadlineTimer ()"; } std::string NetworkOPs::strOperatingMode () @@ -1109,7 +1116,7 @@ void NetworkOPs::pubServer () jvObj ["load_base"] = (mLastLoadBase = getApp().getFeeTrack ().getLoadBase ()); jvObj ["load_factor"] = (mLastLoadFactor = getApp().getFeeTrack ().getLoadFactor ()); - NetworkOPs::subMapType::const_iterator it = mSubServer.begin (); + NetworkOPs::SubMapType::const_iterator it = mSubServer.begin (); while (it != mSubServer.end ()) { @@ -1510,7 +1517,7 @@ void NetworkOPs::pubProposedTransaction (Ledger::ref lpCurrent, SerializedTransa { boost::recursive_mutex::scoped_lock sl (mMonitorLock); - NetworkOPs::subMapType::const_iterator it = mSubRTTransactions.begin (); + NetworkOPs::SubMapType::const_iterator it = mSubRTTransactions.begin (); while (it != mSubRTTransactions.end ()) { @@ -1560,7 +1567,7 @@ void NetworkOPs::pubLedger (Ledger::ref accepted) if (mMode >= omSYNCING) jvObj["validated_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers (); - NetworkOPs::subMapType::const_iterator it = mSubLedger.begin (); + NetworkOPs::SubMapType::const_iterator it = mSubLedger.begin (); while (it != mSubLedger.end ()) { @@ -1642,7 +1649,7 @@ void NetworkOPs::pubValidatedTransaction (Ledger::ref alAccepted, const Accepted { boost::recursive_mutex::scoped_lock sl (mMonitorLock); - NetworkOPs::subMapType::const_iterator it = mSubTransactions.begin (); + NetworkOPs::SubMapType::const_iterator it = mSubTransactions.begin (); while (it != mSubTransactions.end ()) { @@ -1695,7 +1702,7 @@ void NetworkOPs::pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLed if (simiIt != mSubRTAccount.end ()) { - NetworkOPs::subMapType::const_iterator it = simiIt->second.begin (); + NetworkOPs::SubMapType::const_iterator it = simiIt->second.begin (); while (it != simiIt->second.end ()) { @@ -1718,7 +1725,7 @@ void NetworkOPs::pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLed if (simiIt != mSubAccount.end ()) { - NetworkOPs::subMapType::const_iterator it = simiIt->second.begin (); + NetworkOPs::SubMapType::const_iterator it = simiIt->second.begin (); while (it != simiIt->second.end ()) { @@ -1779,7 +1786,7 @@ void NetworkOPs::subAccount (InfoSub::ref isrListener, const boost::unordered_se if (simIterator == subMap.end ()) { // Not found, note that account has a new single listner. - subMapType usisElement; + SubMapType usisElement; usisElement[isrListener->getSeq ()] = isrListener; subMap.insert (simIterator, make_pair (naAccountID.getAccountID (), usisElement)); } diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index f4b4f4e3b6..8500c0a2ec 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -13,7 +13,9 @@ class Peer; class LedgerConsensus; -class NetworkOPs : LeakChecked +class NetworkOPs + : public DeadlineTimer::Listener + , LeakChecked { public: enum Fault @@ -34,6 +36,7 @@ public: }; #if 0 + // VFALCO TODO Make this happen /** Subscription data interface. */ class Subscriber @@ -45,10 +48,10 @@ public: */ virtual void onSubscriberReceiveJSON (Json::Value const& json) { } }; - typedef boost::unordered_map subMapType; + typedef boost::unordered_map SubMapType; #endif - typedef boost::unordered_map subMapType; + typedef boost::unordered_map SubMapType; public: NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster); @@ -352,9 +355,24 @@ public: InfoSub::pointer addRpcSub (const std::string& strUrl, InfoSub::ref rspEntry); private: - typedef boost::unordered_map subInfoMapType; - typedef boost::unordered_map::value_type subInfoMapValue; - typedef boost::unordered_map::iterator subInfoMapIterator; + void onDeadlineTimer (); + + void setMode (OperatingMode); + + Json::Value transJson (const SerializedTransaction& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent); + bool haveConsensusObject (); + + Json::Value pubBootstrapAccountInfo (Ledger::ref lpAccepted, const RippleAddress& naAccountID); + + void pubValidatedTransaction (Ledger::ref alAccepted, const AcceptedLedgerTx& alTransaction); + void pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLedgerTx& alTransaction, bool isAccepted); + + void pubServer (); + +private: + typedef boost::unordered_map subInfoMapType; + typedef boost::unordered_map ::value_type subInfoMapValue; + typedef boost::unordered_map ::iterator subInfoMapIterator; typedef boost::unordered_map subRpcMapType; @@ -363,6 +381,7 @@ private: bool mProposing, mValidating; bool mFeatureBlocked; boost::posix_time::ptime mConnectTime; + //DeadlineTimer m_netTimer; boost::asio::deadline_timer mNetTimer; boost::shared_ptr mConsensus; boost::unordered_map < uint160, @@ -390,10 +409,10 @@ private: subRpcMapType mRpcSubMap; - subMapType mSubLedger; // accepted ledgers - subMapType mSubServer; // when server changes connectivity state - subMapType mSubTransactions; // all accepted transactions - subMapType mSubRTTransactions; // all proposed and accepted transactions + SubMapType mSubLedger; // accepted ledgers + SubMapType mSubServer; // when server changes connectivity state + SubMapType mSubTransactions; // all accepted transactions + SubMapType mSubRTTransactions; // all proposed and accepted transactions TaggedCache< uint256, Blob , UptimeTimerAdapter > mFetchPack; uint32 mLastFetchPack; @@ -406,19 +425,6 @@ private: uint32 mLastLoadBase; uint32 mLastLoadFactor; - - void setMode (OperatingMode); - - Json::Value transJson (const SerializedTransaction& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent); - bool haveConsensusObject (); - - Json::Value pubBootstrapAccountInfo (Ledger::ref lpAccepted, const RippleAddress& naAccountID); - - void pubValidatedTransaction (Ledger::ref alAccepted, const AcceptedLedgerTx& alTransaction); - void pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLedgerTx& alTransaction, bool isAccepted); - - void pubServer (); }; #endif -// vim:ts=4 diff --git a/src/cpp/ripple/OrderBookDB.cpp b/src/cpp/ripple/OrderBookDB.cpp index c08eff968c..8392ac23e8 100644 --- a/src/cpp/ripple/OrderBookDB.cpp +++ b/src/cpp/ripple/OrderBookDB.cpp @@ -224,7 +224,7 @@ void BookListeners::publish (Json::Value& jvObj) std::string sObj = jfwWriter.write (jvObj); boost::recursive_mutex::scoped_lock sl (mLock); - NetworkOPs::subMapType::const_iterator it = mListeners.begin (); + NetworkOPs::SubMapType::const_iterator it = mListeners.begin (); while (it != mListeners.end ()) {