- 
                Notifications
    You must be signed in to change notification settings 
- Fork 421
move static channelmanager functions into their own file #2739
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
move static channelmanager functions into their own file #2739
Conversation
f96fa30    to
    3df33e1      
    Compare
  
    | I think  | 
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe thanks for catching that!
bfeded7    to
    2a63f5f      
    Compare
  
    | 
 Good point, I renamed the module to  | 
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.
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
          
        
      | /// generated using `get_fake_scid` from the scid_utils::fake_scid module. | ||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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  | 
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.
Code review ACK
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.
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.