move static channelmanager functions into their own file#2739
Conversation
f96fa30 to
3df33e1
Compare
|
I think |
shaavan
left a comment
There was a problem hiding this comment.
Concept ACK
The refactoring looks fantastic on my initial review, and the additional comments are really helpful! I'll take another pass at the added code to see if there are any further improvements we can make to this pull request. Superb work!
lightning/src/ln/channelmanager.rs
Outdated
| incoming_cltv_expiry: u32, | ||
| /// Optional shared secret for phantom node. | ||
| /// Shared secret derived using a phantom node secret key. If this field is Some, the | ||
| /// payment was sent to a phantom node (one hop behond the current node), but can be |
There was a problem hiding this comment.
small nit:
| /// payment was sent to a phantom node (one hop behond the current node), but can be | |
| /// payment was sent to a phantom node (one hop behind the current node), but can be |
There was a problem hiding this comment.
hehe thanks for catching that!
bfeded7 to
2a63f5f
Compare
Good point, I renamed the module to |
shaavan
left a comment
There was a problem hiding this comment.
ACK mod nit.
This is a refactoring PR that moves static channelmanger functions to their own file.
I have used the following line command to notice the essential differences introduced by refactoring:
git diff HEAD^ --color-moved-ws=ignore-all-space --color-moved=dimmed-zebraEssential Changes in the PR:
- Updated comments for members of
PendingHTLCRoutingenum. The comments look clean and clear and present a better understanding of the member variables. - Modified the visibility of moved code to pub(super). Since these are utilities of
channelManagerand are not meant to be used in the rest of the codebase, this visibility is the most apt one for it. - Removed
create_payment_onionfunction. Instead, use thecreate_payment_onionfunction defined inln::onion_utils::create_payment_onion;
The refactoring looks clean and clear, and other than the small nits, this PR is good to be merged.
lightning/src/ln/channelmanager.rs
Outdated
| @@ -118,14 +119,19 @@ pub enum PendingHTLCRouting { | |||
| short_channel_id: u64, // This should be NonZero<u64> eventually when we bump MSRV | |||
| }, | |||
| /// An HTLC paid to an invoice we generated. | |||
There was a problem hiding this comment.
Small nit:
In the following line, we are saying we don't know yet if the invoice was generated by us. So adding a "supposedly" will make the comments more coherent here.
| /// An HTLC paid to an invoice we generated. | |
| /// An HTLC paid to an invoice (supposedly) generated by us. |
lightning/src/ln/onion_payment.rs
Outdated
| /// acceptance. If the payment is to be received, and the amount matches the expected amount for | ||
| /// a given invoice, this indicates the [`msgs::UpdateAddHTLC`], once fully committed in the | ||
| /// channel, will generate an [`Event::PaymentClaimable`]. | ||
| /// |
There was a problem hiding this comment.
nit by linter:
| /// | |
| /// |
lightning/src/ln/onion_payment.rs
Outdated
| @@ -0,0 +1,499 @@ | |||
| //! Utilities for channelmanager.rs | |||
| //! | |||
There was a problem hiding this comment.
nit by linter:
| //! | |
| //! |
2a63f5f to
8c588cf
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2739 +/- ##
==========================================
- Coverage 88.55% 88.51% -0.04%
==========================================
Files 113 114 +1
Lines 89323 89305 -18
Branches 89323 89305 -18
==========================================
- Hits 79097 79052 -45
- Misses 7860 7882 +22
- Partials 2366 2371 +5 ☔ View full report in Codecov by Sentry. |
|
ok, rebased to |
valentinewallace
left a comment
There was a problem hiding this comment.
Fine to save these for follow-up if we want to get the initial code move in.
264f367 to
9f4dcd0
Compare
Ok I went ahead and incorporated these nits. Thanks! |
|
Will wait til @TheBlueMatt ACK's the docs to merge. |
|
Going to land this since it's largely a code move and we can continue iterating on the docs if necessary in #2752. |
ln::onion_paymentfile with static functions fromchannelmanager.rs.test_peel_payment_onionand moved intoln::onion_payment.PendingHTLCInfo.payment_hashpublic (mistake from peel_payment_onion static fn in channelmanager #2700).UpdateAddHTLC.onion_routing_packetpublic, so thatpeel_payment_onioncan be used externally.