From be8ce20f73b57b8cc812dc0edbdb3d68dd46be1d Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 17 Jun 2013 13:23:29 -0700 Subject: [PATCH] Don't send redundant ledger queries. Cleanup. --- src/cpp/ripple/ripple_InboundLedger.cpp | 18 +++++++++++------- src/cpp/ripple/ripple_InboundLedger.h | 2 -- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cpp/ripple/ripple_InboundLedger.cpp b/src/cpp/ripple/ripple_InboundLedger.cpp index 0fa7b0cc5d..c3e7ee1b03 100644 --- a/src/cpp/ripple/ripple_InboundLedger.cpp +++ b/src/cpp/ripple/ripple_InboundLedger.cpp @@ -289,8 +289,7 @@ void InboundLedger::trigger (Peer::ref peer) if ((mWaitCount > 0) && peer) { - mRecentPeers.push_back (peer->getPeerId ()); - WriteLog (lsTRACE, InboundLedger) << "Deferring peer"; + WriteLog (lsTRACE, InboundLedger) << "Skipping peer"; return; } @@ -314,6 +313,7 @@ void InboundLedger::trigger (Peer::ref peer) if (mFailed) { WriteLog (lsWARNING, InboundLedger) << " failed local for " << mHash; + return; } } @@ -401,6 +401,7 @@ void InboundLedger::trigger (Peer::ref peer) * (tmGL.add_nodeids ()) = SHAMapNode ().getRawString (); WriteLog (lsTRACE, InboundLedger) << "Sending TX root request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); + return; } else { @@ -431,13 +432,14 @@ void InboundLedger::trigger (Peer::ref peer) if (!nodeIDs.empty ()) { tmGL.set_itype (protocol::liTX_NODE); - BOOST_FOREACH (SHAMapNode & it, nodeIDs) + BOOST_FOREACH (SHAMapNode const& it, nodeIDs) { * (tmGL.add_nodeids ()) = it.getRawString (); } WriteLog (lsTRACE, InboundLedger) << "Sending TX node " << nodeIDs.size () << " request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); + return; } } } @@ -454,6 +456,7 @@ void InboundLedger::trigger (Peer::ref peer) * (tmGL.add_nodeids ()) = SHAMapNode ().getRawString (); WriteLog (lsTRACE, InboundLedger) << "Sending AS root request to " << (peer ? "selected peer" : "all peers"); sendRequest (tmGL, peer); + return; } else { @@ -484,19 +487,20 @@ void InboundLedger::trigger (Peer::ref peer) if (!nodeIDs.empty ()) { tmGL.set_itype (protocol::liAS_NODE); - BOOST_FOREACH (SHAMapNode & it, nodeIDs) - * (tmGL.add_nodeids ()) = it.getRawString (); + BOOST_FOREACH (SHAMapNode const& it, nodeIDs) + { + * (tmGL.add_nodeids ()) = it.getRawString (); + } WriteLog (lsTRACE, InboundLedger) << "Sending AS node " << nodeIDs.size () << " request to " << (peer ? "selected peer" : "all peers"); CondLog (nodeIDs.size () == 1, lsTRACE, InboundLedger) << "AS node: " << nodeIDs[0]; sendRequest (tmGL, peer); + return; } } } } - mRecentPeers.clear (); - if (mComplete || mFailed) { WriteLog (lsDEBUG, InboundLedger) << "Done:" << (mComplete ? " complete" : "") << (mFailed ? " failed " : " ") diff --git a/src/cpp/ripple/ripple_InboundLedger.h b/src/cpp/ripple/ripple_InboundLedger.h index e712581459..2dd5c2debf 100644 --- a/src/cpp/ripple/ripple_InboundLedger.h +++ b/src/cpp/ripple/ripple_InboundLedger.h @@ -115,8 +115,6 @@ private: std::set mRecentTXNodes; std::set mRecentASNodes; - std::vector mRecentPeers; - std::vector > mOnComplete; };