@@ -49,6 +49,13 @@ namespace llarp::path
49
49
: _running{true }, num_paths_desired{num_paths}, _router{_r}, num_hops{_n_hops}
50
50
{}
51
51
52
+ void PathHandler::path_rotation_succeeded (std::shared_ptr<Path> new_path)
53
+ {
54
+ log ::trace (logcat, " {} called" , __PRETTY_FUNCTION__);
55
+ path_build_succeeded (std::move (new_path));
56
+ drop_oldest_path ();
57
+ }
58
+
52
59
static constexpr auto path_map_comp = [comp = PathExpComp{}](auto lhs, auto rhs) -> bool {
53
60
// invert parameters passed so ranges::{min,max}_element use it like operator<
54
61
return comp (rhs.second , lhs.second );
@@ -62,6 +69,14 @@ namespace llarp::path
62
69
return std::ranges::min_element (_paths, path_map_comp)->second ;
63
70
}
64
71
72
+ std::shared_ptr<Path> PathHandler::get_newest_path ()
73
+ {
74
+ log ::trace (logcat, " {} called" , __PRETTY_FUNCTION__);
75
+
76
+ Lock_t l{paths_mutex};
77
+ return std::ranges::max_element (_paths, path_map_comp)->second ;
78
+ }
79
+
65
80
void PathHandler::print_all_paths () const
66
81
{
67
82
log ::trace (logcat, " {} called" , __PRETTY_FUNCTION__);
@@ -241,7 +256,7 @@ namespace llarp::path
241
256
}
242
257
}
243
258
244
- intro_set PathHandler::get_current_client_intros () const
259
+ intro_set PathHandler::get_local_client_intros () const
245
260
{
246
261
Lock_t lock{paths_mutex};
247
262
@@ -844,21 +859,6 @@ namespace llarp::path
844
859
}
845
860
}
846
861
847
- // void PathHandler::rotate_paths(
848
- // std::vector<RemoteRC> hops, std::function<void(std::shared_ptr<Path>)> success_cb, path_build_fail_hook
849
- // fail_cb)
850
- // {
851
- // log::trace(logcat, "{} called", __PRETTY_FUNCTION__);
852
-
853
- // if (auto new_path = build1(hops))
854
- // {
855
- // assert(new_path);
856
-
857
- // log::debug(logcat, "Attempting path-rotation to new path...");
858
- // path_build_onepass(std::move(new_path), std::move(success_cb), std::move(fail_cb));
859
- // }
860
- // }
861
-
862
862
void PathHandler::rotate_paths (std::vector<RemoteRC> hops)
863
863
{
864
864
log ::trace (logcat, " {} called" , __PRETTY_FUNCTION__);
0 commit comments