Exemple #1
0
void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL, Peer::ref peer)
{
    if (!peer)
        sendRequest (tmGL);
    else
        peer->sendPacket (boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER), false);
}
Exemple #2
0
void PeerSet::peerHas (Peer::ref ptr)
{
    boost::recursive_mutex::scoped_lock sl (mLock);

    if (!mPeers.insert (std::make_pair (ptr->getPeerId (), 0)).second)
        return;

    newPeer (ptr);
}
Exemple #3
0
bool PeerSet::peerHas (Peer::ref ptr)
{
    ScopedLockType sl (mLock, __FILE__, __LINE__);

    if (!mPeers.insert (std::make_pair (ptr->getPeerId (), 0)).second)
        return false;

    newPeer (ptr);
    return true;
}
Exemple #4
0
    /** A peer has connected successfully
        This is called after the peer handshake has been completed and during
        peer activation. At this point, the peer address and the public key
        are known.
    */
    void onPeerActivated (Peer::ref peer)
    {
        // First assign this peer a new short ID
        peer->setShortId(++m_nextShortId);

        std::lock_guard <decltype(m_mutex)> lock (m_mutex);

        // Now track this peer
        std::pair<PeerByShortId::iterator, bool> idResult(
            m_shortIdMap.emplace (
                boost::unordered::piecewise_construct,
                boost::make_tuple (peer->getShortId()),
                boost::make_tuple (peer)));
        check_postcondition(idResult.second);

        std::pair<PeerByPublicKey::iterator, bool> keyResult(
            m_publicKeyMap.emplace (
                boost::unordered::piecewise_construct,
                boost::make_tuple (peer->getNodePublic()),
                boost::make_tuple (peer)));
        check_postcondition(keyResult.second);

        m_journal.debug << 
            "activated " << peer->getRemoteAddress() <<
            " (" << peer->getShortId() << 
            ":" << RipplePublicKey(peer->getNodePublic()) << ")";

        // We just accepted this peer so we have non-zero active peers
        check_postcondition(size() != 0);
    }
Exemple #5
0
void PeerSet::badPeer (Peer::ref ptr)
{
    ScopedLockType sl (mLock, __FILE__, __LINE__);
    mPeers.erase (ptr->getPeerId ());
}
void PeerSet::badPeer (Peer::ref ptr)
{
    boost::recursive_mutex::scoped_lock sl (mLock);
    mPeers.erase (ptr->getPeerId ());
}
Exemple #7
0
 void operator() (Peer::ref peer)
 {
     json.append (peer->json ());
 }
Exemple #8
0
 /** A peer is being disconnected
     This is called during the disconnection of a known, activated peer. It
     will not be called for outbound peer connections that don't succeed or
     for connections of peers that are dropped prior to being activated.
 */
 void onPeerDisconnect (Peer::ref peer)
 {
     std::lock_guard <decltype(m_mutex)> lock (m_mutex);
     m_shortIdMap.erase (peer->getShortId ());
     m_publicKeyMap.erase (peer->getNodePublic ());
 }