mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
7caa87862e
All #ifndef guards on headers have been removed, I think, in favor of #pragma once Headers are now included as `#include "filename"` if the included file resides in the same directory as the file including it, or any subdirectory therein. Otherwise they are included as `#include <project/top/dir/relative/path/filename>` The above does not include system/os headers.
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "endpoint_types.hpp"
|
|
|
|
namespace llarp
|
|
{
|
|
namespace service
|
|
{
|
|
struct EndpointUtil
|
|
{
|
|
static void
|
|
ExpireSNodeSessions(llarp_time_t now, SNodeSessions& sessions);
|
|
|
|
static void
|
|
ExpirePendingTx(llarp_time_t now, PendingLookups& lookups);
|
|
|
|
static void
|
|
ExpirePendingRouterLookups(llarp_time_t now, PendingRouters& routers);
|
|
|
|
static void
|
|
DeregisterDeadSessions(llarp_time_t now, Sessions& sessions);
|
|
|
|
static void
|
|
TickRemoteSessions(
|
|
llarp_time_t now, Sessions& remoteSessions, Sessions& deadSessions, ConvoMap& sessions);
|
|
|
|
static void
|
|
ExpireConvoSessions(llarp_time_t now, ConvoMap& sessions);
|
|
|
|
static void
|
|
StopRemoteSessions(Sessions& remoteSessions);
|
|
|
|
static void
|
|
StopSnodeSessions(SNodeSessions& sessions);
|
|
|
|
static bool
|
|
HasPathToService(const Address& addr, const Sessions& remoteSessions);
|
|
|
|
static bool
|
|
GetConvoTagsForService(
|
|
const ConvoMap& sessions, const Address& addr, std::set<ConvoTag>& tags);
|
|
};
|
|
|
|
template <typename Endpoint_t>
|
|
static path::Path::UniqueEndpointSet_t
|
|
GetManyPathsWithUniqueEndpoints(Endpoint_t* ep, size_t N, size_t tries = 10)
|
|
{
|
|
path::Path::UniqueEndpointSet_t paths;
|
|
do
|
|
{
|
|
--tries;
|
|
const auto path = ep->PickRandomEstablishedPath();
|
|
if (path)
|
|
paths.emplace(path);
|
|
} while (tries > 0 and paths.size() < N);
|
|
return paths;
|
|
}
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|