/** 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); }
/** 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 ()); }