Beispiel #1
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
OverlayImpl::onPeerActivated (Peer::ptr const& peer)
{
    std::lock_guard <decltype(m_mutex)> lock (m_mutex);

    // Now track this peer
    {
        auto const result (m_shortIdMap.emplace (
                               std::piecewise_construct,
                               std::make_tuple (peer->getShortId()),
                               std::make_tuple (peer)));
        assert(result.second);
    }

    {
        auto const result (m_publicKeyMap.emplace (
                               std::piecewise_construct,
                               std::make_tuple (peer->getNodePublic()),
                               std::make_tuple (peer)));
        assert(result.second);
    }

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

    // We just accepted this peer so we have non-zero active peers
    assert(size() != 0);
}
Beispiel #2
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
OverlayImpl::onPeerDisconnect (Peer::ptr const& peer)
{
    std::lock_guard <decltype(m_mutex)> lock (m_mutex);
    m_shortIdMap.erase (peer->getShortId ());
    m_publicKeyMap.erase (peer->getNodePublic ());
}
Beispiel #3
0
bool PeerSet::peerHas (Peer::ptr const& ptr)
{
    ScopedLockType sl (mLock);

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

    newPeer (ptr);
    return true;
}
Beispiel #4
0
void PeerSet::badPeer (Peer::ptr const& ptr)
{
    ScopedLockType sl (mLock);
    mPeers.erase (ptr->getShortId ());
}