diff --git a/modules/ripple_app/ledger/ripple_InboundLedger.cpp b/modules/ripple_app/ledger/ripple_InboundLedger.cpp index 0aaf02194..80dddf0e8 100644 --- a/modules/ripple_app/ledger/ripple_InboundLedger.cpp +++ b/modules/ripple_app/ledger/ripple_InboundLedger.cpp @@ -167,10 +167,9 @@ void InboundLedger::onTimer (bool progress, boost::recursive_mutex::scoped_lock& int pc = getPeerCount (); WriteLog (lsDEBUG, InboundLedger) << "No progress(" << pc << ") for ledger " << mHash; + trigger (Peer::pointer ()); if (pc < 3) addPeers (); - else - trigger (Peer::pointer ()); } } @@ -211,10 +210,8 @@ void InboundLedger::addPeers () if (peer->hasLedger (getHash (), mSeq)) { - peerHas (peer); - - if (++found == 3) - break; + if (peerHas (peer) && (++found == 3)) + break; } } @@ -812,8 +809,12 @@ Json::Value InboundLedger::getJson (int) ret["peers"] = static_cast(mPeers.size()); ret["have_base"] = mHaveBase; - ret["have_state"] = mHaveState; - ret["have_transactions"] = mHaveTransactions; + + if (mHaveBase) + { + ret["have_state"] = mHaveState; + ret["have_transactions"] = mHaveTransactions; + } if (mAborted) ret["aborted"] = true; @@ -823,7 +824,7 @@ Json::Value InboundLedger::getJson (int) if (mHaveBase && !mHaveState) { Json::Value hv (Json::arrayValue); - std::vector v = mLedger->peekAccountStateMap ()->getNeededHashes (16, NULL); + std::vector v = mLedger->getNeededAccountStateHashes (16, NULL); BOOST_FOREACH (uint256 const & h, v) { hv.append (h.GetHex ()); @@ -834,7 +835,7 @@ Json::Value InboundLedger::getJson (int) if (mHaveBase && !mHaveTransactions) { Json::Value hv (Json::arrayValue); - std::vector v = mLedger->peekTransactionMap ()->getNeededHashes (16, NULL); + std::vector v = mLedger->getNeededTransactionHashes (16, NULL); BOOST_FOREACH (uint256 const & h, v) { hv.append (h.GetHex ()); diff --git a/modules/ripple_app/peers/ripple_PeerSet.cpp b/modules/ripple_app/peers/ripple_PeerSet.cpp index 9ef897fa7..3a278f814 100644 --- a/modules/ripple_app/peers/ripple_PeerSet.cpp +++ b/modules/ripple_app/peers/ripple_PeerSet.cpp @@ -21,14 +21,15 @@ PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData) assert ((mTimerInterval > 10) && (mTimerInterval < 30000)); } -void PeerSet::peerHas (Peer::ref ptr) +bool PeerSet::peerHas (Peer::ref ptr) { boost::recursive_mutex::scoped_lock sl (mLock); if (!mPeers.insert (std::make_pair (ptr->getPeerId (), 0)).second) - return; + return false; newPeer (ptr); + return true; } void PeerSet::badPeer (Peer::ref ptr) diff --git a/modules/ripple_app/peers/ripple_PeerSet.h b/modules/ripple_app/peers/ripple_PeerSet.h index b61336fb2..73e55e6a0 100644 --- a/modules/ripple_app/peers/ripple_PeerSet.h +++ b/modules/ripple_app/peers/ripple_PeerSet.h @@ -50,7 +50,7 @@ public: return mLastAction; } - void peerHas (Peer::ref); + bool peerHas (Peer::ref); void badPeer (Peer::ref); void setTimer ();