-
Notifications
You must be signed in to change notification settings - Fork 411
Log penalty info in route-success line #1300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log penalty info in route-success line #1300
Conversation
We make this a tuple to track the paths and their corresponding penalties. I made this decision over creating a separate `path_penalties` vector so we don't run the risk of having to handle the scenario where `selected_paths.len() != path_penalties.len()`.
To leverage the log_route! macro, we want to add a field to the Route struct. This commit adds the `path_penalties` field, which will contain the penalties to `paths`.
Codecov Report
@@ Coverage Diff @@
## main #1300 +/- ##
==========================================
- Coverage 90.51% 90.48% -0.03%
==========================================
Files 71 71
Lines 39012 39025 +13
==========================================
+ Hits 35310 35313 +3
- Misses 3702 3712 +10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't leave a comment there (thanks GitHub...) but maybe instead of changing the public API a bunch we could try to clean up the output printed at L1319 (presumably by doing a custom debug representation of PathBuildingHop instead of the default one).
@@ -76,6 +76,9 @@ pub struct Route { | |||
/// | |||
/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed | |||
pub payment_params: Option<PaymentParameters>, | |||
/// List of penalties corresponding to the paths in the `paths` vector. | |||
/// This is populated by taking the last [`PathBuildingHop`] of every path found in [`find_route`] | |||
pub path_penalties: Vec<u64>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, do we care about actually exposing this programmatically? Presumably the user can just call their own scorer immediately after getting the route if they really want this info. I think just logging it may be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @TheBlueMatt, thanks for taking a look! that is a good suggestion -- I'll change my implementation. I will take another stab over the weekend :)
attempting different implementation, closing. |
This PR is an attempt at #1233.
My goal is to be able to leverage on the existing
log_route!
macro to print the penalties for each path found within a route, which meant making the penalty data available somehow in theRoute
struct.I think this contribution can be improved by adding test coverage, but am struggling to figure out where to add them. Suggestions welcome!
I'm new to Rust + contributing to open-source, so please feel free to leave feedback! I am also happy to change the implementation if adding a field to Route is not something we want to pursue.
Thanks!
Demo
This is the old output for routes (ran via
routing::router::tests::simple_route_test
):New (diff in ****):