diff --git a/modules/ripple_app/ledger/LedgerMaster.cpp b/modules/ripple_app/ledger/LedgerMaster.cpp index bb58a2163..bed082bc7 100644 --- a/modules/ripple_app/ledger/LedgerMaster.cpp +++ b/modules/ripple_app/ledger/LedgerMaster.cpp @@ -364,16 +364,10 @@ void LedgerMaster::tryFill (Ledger::pointer ledger) void LedgerMaster::getFetchPack (Ledger::ref nextLedger) { - protocol::TMGetObjectByHash tmBH; - tmBH.set_type (protocol::TMGetObjectByHash::otFETCH_PACK); - tmBH.set_query (true); - tmBH.set_seq (nextLedger->getLedgerSeq()); - tmBH.set_ledgerhash (nextLedger->getHash().begin (), 32); - std::vector peerList = getApp().getPeers ().getPeerVector (); - Peer::pointer target; int count = 0; + std::vector peerList = getApp().getPeers ().getPeerVector (); BOOST_FOREACH (const Peer::pointer & peer, peerList) { if (peer->hasRange (nextLedger->getLedgerSeq() - 1, nextLedger->getLedgerSeq())) @@ -387,7 +381,12 @@ void LedgerMaster::getFetchPack (Ledger::ref nextLedger) if (target) { + protocol::TMGetObjectByHash tmBH; + tmBH.set_query (true); + tmBH.set_type (protocol::TMGetObjectByHash::otFETCH_PACK); + tmBH.set_ledgerhash (nextLedger->getHash().begin (), 32); PackedMessage::pointer packet = boost::make_shared (tmBH, protocol::mtGET_OBJECTS); + target->sendPacket (packet, false); WriteLog (lsTRACE, LedgerMaster) << "Requested fetch pack for " << nextLedger->getLedgerSeq() - 1; } diff --git a/modules/ripple_app/ledger/ripple_InboundLedgers.cpp b/modules/ripple_app/ledger/ripple_InboundLedgers.cpp index d3e8bc3e6..2f1f6c07c 100644 --- a/modules/ripple_app/ledger/ripple_InboundLedgers.cpp +++ b/modules/ripple_app/ledger/ripple_InboundLedgers.cpp @@ -32,27 +32,34 @@ InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 s WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have: " << hash; } + assert (mLedgers[hash]); return ptr; } InboundLedger::pointer InboundLedgers::find (uint256 const& hash) { assert (hash.isNonZero ()); - boost::mutex::scoped_lock sl (mLock); - std::map::iterator it = mLedgers.find (hash); - if (it != mLedgers.end ()) + InboundLedger::pointer ret; + { - it->second->touch (); - return it->second; + boost::mutex::scoped_lock sl (mLock); + + std::map::iterator it = mLedgers.find (hash); + if (it != mLedgers.end ()) + { + it->second->touch (); + ret = it->second; + } } - return InboundLedger::pointer (); + return ret; } bool InboundLedgers::hasLedger (uint256 const& hash) { assert (hash.isNonZero ()); + boost::mutex::scoped_lock sl (mLock); return mLedgers.find (hash) != mLedgers.end (); } @@ -60,6 +67,7 @@ bool InboundLedgers::hasLedger (uint256 const& hash) void InboundLedgers::dropLedger (uint256 const& hash) { assert (hash.isNonZero ()); + boost::mutex::scoped_lock sl (mLock); mLedgers.erase (hash); } @@ -254,7 +262,10 @@ void InboundLedgers::gotFetchPack (Job&) acquires.reserve (mLedgers.size ()); typedef std::pair u256_acq_pair; BOOST_FOREACH (const u256_acq_pair & it, mLedgers) - acquires.push_back (it.second); + { + assert (it.second); + acquires.push_back (it.second); + } } BOOST_FOREACH (const InboundLedger::pointer & acquire, acquires) @@ -282,7 +293,10 @@ Json::Value InboundLedgers::getInfo() acquires.reserve (mLedgers.size ()); BOOST_FOREACH (const u256_acq_pair & it, mLedgers) - acquires.push_back (it); + { + assert (it.second); + acquires.push_back (it); + } } BOOST_FOREACH (const u256_acq_pair& it, acquires)