-
Notifications
You must be signed in to change notification settings - Fork 385
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
Add method to count total fees in a Route #999 #1063
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1063 +/- ##
==========================================
- Coverage 90.82% 90.74% -0.08%
==========================================
Files 65 65
Lines 32890 33948 +1058
==========================================
+ Hits 29872 30806 +934
- Misses 3018 3142 +124
Continue to review full report at Codecov.
|
…devkit#999 * Added `get_total_fees` method to route, to calculate all the fees paid accross each path. * Added `get_total_amount` method to route, to calculate the total of actual amounts paid in each path.
03aaa9d
to
03bb808
Compare
Reworked unit tests and added an extra |
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.
Just nits, LGTM
/// This doesn't include any extra payment made to the recipient, | ||
/// which can happen in excess of the amount passed to `get_route`'s `final_value_msat`. |
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.
nit: lines should be 100chars each
.flat_map(|path| path.split_last().unwrap().1) | ||
.map(|hop| &hop.fee_msat) | ||
.sum(); | ||
} |
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.
nit: newline below
.map(|hop| &hop.fee_msat) | ||
.sum(); | ||
} | ||
/// Returns the total amount paid on this Route, excluding the fees. |
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.
nit: ticks around Route
and above
.sum(); | ||
} | ||
/// Returns the total amount paid on this Route, excluding the fees. | ||
pub fn get_total_amount(&self) -> 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.
Idk if it's worth noting for these methods that they'll panic for 0-length routes?
RouteHop { | ||
pubkey: PublicKey::from_slice(&hex::decode("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(), | ||
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(), | ||
short_channel_id: 0, fee_msat: 100, cltv_expiry_delta: 0 // Test vectors are garbage and not generateble from a RouteHop, we fill in payloads manually |
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.
nit here and below: s/generateble/generatable (i think these comments can all be deleted though 😛)
Gonna land this, will handle val's comments in a new PR. |
Part of #999. Add a member function for Route that returns the total amount of fees paid across all paths.
Further work will be carried out following @valentinewallace's work in #1053, so that the same can be calculated post payment. This implies taking into account which payments were really confirmed and discard what failed or was retried.