Пример #1
0
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));
}
Пример #2
0
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);
    }
}
Пример #3
0
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;
}
Пример #4
0
void PeerSet::badPeer (Peer::ptr const& ptr)
{
    ScopedLockType sl (mLock);
    mPeers.erase (ptr->getShortId ());
}
Пример #5
0
 void operator() (Peer::ptr const& peer)
 {
     json.append (peer->json ());
 }