20 #include <ripple/app/main/Application.h>
21 #include <ripple/core/JobQueue.h>
22 #include <ripple/overlay/Overlay.h>
23 #include <ripple/overlay/PeerSet.h>
27 using namespace std::chrono_literals;
41 , mTimerInterval(interval)
42 , mTimer(app_.getIOService())
61 overlay.foreach([&](
auto const& peer) {
62 auto const score = peer->getScore(hasItem(peer));
69 [](ScoredPeer
const& lhs, ScoredPeer
const& rhs) {
70 return lhs.first > rhs.first;
75 for (
auto const& pair : pairs)
77 auto const peer = pair.second;
78 if (!
mPeers.insert(peer->id()).second)
91 [wptr =
pmDowncast()](boost::system::error_code
const& ec) {
92 if (ec == boost::asio::error::operation_aborted)
95 if (
auto ptr = wptr.lock())
113 <<
" acquiring " <<
mHash;
128 const protocol::TMGetLedger& tmGL,
131 auto packet = std::make_shared<Message>(tmGL, protocol::mtGET_LEDGER);
virtual void onTimer(bool progress, ScopedLockType &)=0
Hook called from invokeOnTimer().
bool mProgress
Whether forward progress has been made.
void invokeOnTimer()
Calls onTimer() if in the right state.
boost::asio::basic_waitable_timer< std::chrono::steady_clock > mTimer
std::set< Peer::id_t > mPeers
The identifiers of the peers we are tracking.
void addPeers(std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> score)
Add at most limit peers to this set from the overlay.
const uint256 mHash
The hash of the object (in practice, always a ledger) we are trying to fetch.
void sendRequest(const protocol::TMGetLedger &message, std::shared_ptr< Peer > const &peer)
Send a GetLedger message to one or all peers.
PeerSet(Application &app, uint256 const &hash, std::chrono::milliseconds interval, beast::Journal journal)
A generic endpoint for log messages.
@ accepted
Manifest is valid.
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual Overlay & overlay()=0
virtual void onPeerAdded(std::shared_ptr< Peer > const &)=0
Hook called from addPeers().
std::chrono::milliseconds mTimerInterval
The minimum time to wait between calls to execute().
virtual std::weak_ptr< PeerSet > pmDowncast()=0
Return a weak pointer to this.
void setTimer()
Schedule a call to queueJob() after mTimerInterval.
virtual std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id)=0
Returns the peer with the matching short id, or null.
std::recursive_mutex mLock