void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL, Peer::ptr const& peer) { if (!peer) sendRequest (tmGL); else peer->send (std::make_shared<Message> (tmGL, protocol::mtGET_LEDGER)); }
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL) { ScopedLockType sl (mLock); if (mPeers.empty ()) return; Message::pointer packet ( std::make_shared<Message> (tmGL, protocol::mtGET_LEDGER)); for (auto const& p : mPeers) { Peer::ptr peer (app_.overlay ().findPeerByShortID (p.first)); if (peer) peer->send (packet); } }
bool PeerSet::insert (Peer::ptr const& ptr) { ScopedLockType sl (mLock); if (!mPeers.insert (std::make_pair (ptr->id (), 0)).second) return false; newPeer (ptr); return true; }
void PeerSet::badPeer (Peer::ptr const& ptr) { ScopedLockType sl (mLock); mPeers.erase (ptr->getShortId ()); }
void operator() (Peer::ptr const& peer) { json.append (peer->json ()); }