1#include <xrpld/peerfinder/detail/SlotImp.h>
3#include <xrpld/peerfinder/PeerfinderManager.h>
4#include <xrpld/peerfinder/Slot.h>
5#include <xrpld/peerfinder/detail/Tuning.h>
7#include <xrpl/beast/container/detail/aged_unordered_container.h>
8#include <xrpl/beast/net/IPEndpoint.h>
9#include <xrpl/beast/utility/instrumentation.h>
54 state !=
State::Active,
"xrpl::PeerFinder::SlotImp::state : input state is not active");
59 "xrpl::PeerFinder::SlotImp::state : input state is different from "
65 "xrpl::PeerFinder::SlotImp::state : input state is not an initial");
70 "xrpl::PeerFinder::SlotImp::state : input state is not connected an "
76 "xrpl::PeerFinder::SlotImp::state : input state is not closing an "
88 "xrpl::PeerFinder::SlotImp::activate : valid state");
107 auto const result(
cache_.emplace(ep, hops));
111 if (hops <= result.first->second)
113 result.first->second = hops;
114 cache_.touch(result.first);
122 auto const iter(
cache_.find(ep));
128 return iter->second <= hops;
std::chrono::steady_clock::time_point time_point
A version-independent IP address and port combination.
beast::aged_unordered_map< beast::IP::Endpoint, std::uint32_t > cache_
RecentT(clock_type &clock)
bool filter(beast::IP::Endpoint const &ep, std::uint32_t hops)
Returns true if we should not send endpoint to the slot.
void insert(beast::IP::Endpoint const &ep, std::uint32_t hops)
Called for each valid endpoint received for a slot.
static constexpr std::int32_t kUnknownPort
bool fixed() const override
Returns true if this is a fixed connection.
class xrpl::PeerFinder::SlotImp::RecentT recent
SlotImp(beast::IP::Endpoint const &localEndpoint, beast::IP::Endpoint remoteEndpoint, bool fixed, clock_type &clock)
std::atomic< std::int32_t > listeningPort_
std::optional< beast::IP::Endpoint > const & localEndpoint() const override
The local endpoint of the socket, when known.
State state() const override
Returns the state of the connection.
bool connectivityCheckInProgress
clock_type::time_point whenAcceptEndpoints
beast::IP::Endpoint const & remoteEndpoint() const override
The remote endpoint of socket.
beast::IP::Endpoint remoteEndpoint_
std::optional< beast::IP::Endpoint > localEndpoint_
void activate(clock_type::time_point const &now)
std::enable_if_t< IsAgedContainer< AgedContainer >::value, std::size_t > expire(AgedContainer &c, std::chrono::duration< Rep, Period > const &age)
Expire aged container items past the specified age.
constexpr std::chrono::seconds kLiveCacheSecondsToLive(30)
beast::AbstractClock< std::chrono::steady_clock > clock_type