mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
6 years ago
|
#ifndef LLARP_PATHSET_HPP
|
||
|
#define LLARP_PATHSET_HPP
|
||
|
|
||
|
#include <llarp/path_types.hpp>
|
||
|
#include <map>
|
||
|
#include <tuple>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
namespace path
|
||
|
{
|
||
|
enum PathStatus
|
||
|
{
|
||
|
ePathBuilding,
|
||
|
ePathEstablished,
|
||
|
ePathTimeout,
|
||
|
ePathExpired
|
||
|
};
|
||
|
// forward declare
|
||
|
struct Path;
|
||
|
|
||
|
/// a set of paths owned by an entity
|
||
|
struct PathSet
|
||
|
{
|
||
|
/// construct
|
||
|
/// @params numPaths the number of paths to maintain
|
||
|
PathSet(size_t numPaths);
|
||
|
|
||
|
void
|
||
|
RemovePath(Path* path);
|
||
|
|
||
|
void
|
||
|
HandlePathBuilt(Path* path);
|
||
|
|
||
|
void
|
||
|
AddPath(Path* path);
|
||
|
|
||
|
Path*
|
||
|
GetByUpstream(const RouterID& remote, const PathID_t& rxid);
|
||
|
|
||
|
void
|
||
|
ExpirePaths(llarp_time_t now);
|
||
|
|
||
|
size_t
|
||
|
NumInStatus(PathStatus st) const;
|
||
|
|
||
|
/// return true if we should build another path
|
||
|
bool
|
||
|
ShouldBuildMore() const;
|
||
|
|
||
|
private:
|
||
|
typedef std::map< PathID_t, Path* > PathMap_t;
|
||
|
// (tx,rx)
|
||
|
typedef std::tuple< PathMap_t, PathMap_t > PathContainer_t;
|
||
|
|
||
|
size_t m_NumPaths;
|
||
|
PathContainer_t m_Paths;
|
||
|
};
|
||
|
|
||
|
} // namespace path
|
||
|
} // namespace llarp
|
||
|
|
||
|
#endif
|