Rename SubMapType

This commit is contained in:
Vinnie Falco
2013-07-08 12:40:28 -07:00
parent b1943dd6eb
commit a84f7e2eb5
3 changed files with 44 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ NetworkOPs::NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedg
, mProposing (false) , mProposing (false)
, mValidating (false) , mValidating (false)
, mFeatureBlocked (false) , mFeatureBlocked (false)
//, m_netTimer (this)
, mNetTimer (io_service) , mNetTimer (io_service)
, mLedgerMaster (pLedgerMaster) , mLedgerMaster (pLedgerMaster)
, mCloseTimeOffset (0) , mCloseTimeOffset (0)
@@ -38,6 +39,12 @@ NetworkOPs::NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedg
, mLastLoadBase (256) , mLastLoadBase (256)
, mLastLoadFactor (256) , mLastLoadFactor (256)
{ {
// m_netTimer.setExpirationRecurring (LEDGER_GRANULARITY / 1000.0);
}
void NetworkOPs::onDeadlineTimer ()
{
// WriteLog (lsINFO, NetworkOPs) << "NetworkOPs::onDeadlineTimer ()";
} }
std::string NetworkOPs::strOperatingMode () std::string NetworkOPs::strOperatingMode ()
@@ -1109,7 +1116,7 @@ void NetworkOPs::pubServer ()
jvObj ["load_base"] = (mLastLoadBase = getApp().getFeeTrack ().getLoadBase ()); jvObj ["load_base"] = (mLastLoadBase = getApp().getFeeTrack ().getLoadBase ());
jvObj ["load_factor"] = (mLastLoadFactor = getApp().getFeeTrack ().getLoadFactor ()); 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 ()) while (it != mSubServer.end ())
{ {
@@ -1510,7 +1517,7 @@ void NetworkOPs::pubProposedTransaction (Ledger::ref lpCurrent, SerializedTransa
{ {
boost::recursive_mutex::scoped_lock sl (mMonitorLock); 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 ()) while (it != mSubRTTransactions.end ())
{ {
@@ -1560,7 +1567,7 @@ void NetworkOPs::pubLedger (Ledger::ref accepted)
if (mMode >= omSYNCING) if (mMode >= omSYNCING)
jvObj["validated_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers (); jvObj["validated_ledgers"] = getApp().getLedgerMaster ().getCompleteLedgers ();
NetworkOPs::subMapType::const_iterator it = mSubLedger.begin (); NetworkOPs::SubMapType::const_iterator it = mSubLedger.begin ();
while (it != mSubLedger.end ()) while (it != mSubLedger.end ())
{ {
@@ -1642,7 +1649,7 @@ void NetworkOPs::pubValidatedTransaction (Ledger::ref alAccepted, const Accepted
{ {
boost::recursive_mutex::scoped_lock sl (mMonitorLock); 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 ()) while (it != mSubTransactions.end ())
{ {
@@ -1695,7 +1702,7 @@ void NetworkOPs::pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLed
if (simiIt != mSubRTAccount.end ()) 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 ()) while (it != simiIt->second.end ())
{ {
@@ -1718,7 +1725,7 @@ void NetworkOPs::pubAccountTransaction (Ledger::ref lpCurrent, const AcceptedLed
if (simiIt != mSubAccount.end ()) 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 ()) while (it != simiIt->second.end ())
{ {
@@ -1779,7 +1786,7 @@ void NetworkOPs::subAccount (InfoSub::ref isrListener, const boost::unordered_se
if (simIterator == subMap.end ()) if (simIterator == subMap.end ())
{ {
// Not found, note that account has a new single listner. // Not found, note that account has a new single listner.
subMapType usisElement; SubMapType usisElement;
usisElement[isrListener->getSeq ()] = isrListener; usisElement[isrListener->getSeq ()] = isrListener;
subMap.insert (simIterator, make_pair (naAccountID.getAccountID (), usisElement)); subMap.insert (simIterator, make_pair (naAccountID.getAccountID (), usisElement));
} }

View File

@@ -13,7 +13,9 @@
class Peer; class Peer;
class LedgerConsensus; class LedgerConsensus;
class NetworkOPs : LeakChecked <NetworkOPs> class NetworkOPs
: public DeadlineTimer::Listener
, LeakChecked <NetworkOPs>
{ {
public: public:
enum Fault enum Fault
@@ -34,6 +36,7 @@ public:
}; };
#if 0 #if 0
// VFALCO TODO Make this happen
/** Subscription data interface. /** Subscription data interface.
*/ */
class Subscriber class Subscriber
@@ -45,10 +48,10 @@ public:
*/ */
virtual void onSubscriberReceiveJSON (Json::Value const& json) { } virtual void onSubscriberReceiveJSON (Json::Value const& json) { }
}; };
typedef boost::unordered_map <uint64, Subscriber::WeakPtr> subMapType; typedef boost::unordered_map <uint64, Subscriber::WeakPtr> SubMapType;
#endif #endif
typedef boost::unordered_map <uint64, InfoSub::wptr> subMapType; typedef boost::unordered_map <uint64, InfoSub::wptr> SubMapType;
public: public:
NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster); NetworkOPs (boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster);
@@ -352,9 +355,24 @@ public:
InfoSub::pointer addRpcSub (const std::string& strUrl, InfoSub::ref rspEntry); InfoSub::pointer addRpcSub (const std::string& strUrl, InfoSub::ref rspEntry);
private: private:
typedef boost::unordered_map<uint160, subMapType> subInfoMapType; void onDeadlineTimer ();
typedef boost::unordered_map<uint160, subMapType>::value_type subInfoMapValue;
typedef boost::unordered_map<uint160, subMapType>::iterator subInfoMapIterator; 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 <uint160, SubMapType> subInfoMapType;
typedef boost::unordered_map <uint160, SubMapType>::value_type subInfoMapValue;
typedef boost::unordered_map <uint160, SubMapType>::iterator subInfoMapIterator;
typedef boost::unordered_map<std::string, InfoSub::pointer> subRpcMapType; typedef boost::unordered_map<std::string, InfoSub::pointer> subRpcMapType;
@@ -363,6 +381,7 @@ private:
bool mProposing, mValidating; bool mProposing, mValidating;
bool mFeatureBlocked; bool mFeatureBlocked;
boost::posix_time::ptime mConnectTime; boost::posix_time::ptime mConnectTime;
//DeadlineTimer m_netTimer;
boost::asio::deadline_timer mNetTimer; boost::asio::deadline_timer mNetTimer;
boost::shared_ptr<LedgerConsensus> mConsensus; boost::shared_ptr<LedgerConsensus> mConsensus;
boost::unordered_map < uint160, boost::unordered_map < uint160,
@@ -390,10 +409,10 @@ private:
subRpcMapType mRpcSubMap; subRpcMapType mRpcSubMap;
subMapType mSubLedger; // accepted ledgers SubMapType mSubLedger; // accepted ledgers
subMapType mSubServer; // when server changes connectivity state SubMapType mSubServer; // when server changes connectivity state
subMapType mSubTransactions; // all accepted transactions SubMapType mSubTransactions; // all accepted transactions
subMapType mSubRTTransactions; // all proposed and accepted transactions SubMapType mSubRTTransactions; // all proposed and accepted transactions
TaggedCache< uint256, Blob , UptimeTimerAdapter > mFetchPack; TaggedCache< uint256, Blob , UptimeTimerAdapter > mFetchPack;
uint32 mLastFetchPack; uint32 mLastFetchPack;
@@ -406,19 +425,6 @@ private:
uint32 mLastLoadBase; uint32 mLastLoadBase;
uint32 mLastLoadFactor; 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 #endif
// vim:ts=4

View File

@@ -224,7 +224,7 @@ void BookListeners::publish (Json::Value& jvObj)
std::string sObj = jfwWriter.write (jvObj); std::string sObj = jfwWriter.write (jvObj);
boost::recursive_mutex::scoped_lock sl (mLock); 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 ()) while (it != mListeners.end ())
{ {