Skip to content

Conversation

@joostjager
Copy link
Contributor

Cleanup commits to improve the readability and maintainability of the ChannelManager deserialization code.

  • Group the three _legacy fields together in ChannelManagerData to deduplicate their explanatory comment
  • Use consistent unwrap_or_else pattern for optional TLV fields instead of initializing with Some and using unwrap
  • Document the seven logical steps within from_channel_manager_data (stage 2 of deserialization)

joostjager and others added 3 commits February 3, 2026 13:28
Reorder the struct fields to place all three `_legacy` fields together
at the end, allowing the explanatory comment to appear once instead of
being duplicated three times.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Initialize pending_claiming_payments and monitor_update_blocked_actions_per_peer
with None and resolve with unwrap_or_else, matching the pattern used for other
optional hash map fields like pending_intercepted_htlcs_legacy.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add step comments to from_channel_manager_data to clarify the seven
logical phases of ChannelManager reconstruction:

1. Channel/monitor reconciliation
2. Initialize missing optional fields
3. Replay in-flight monitor updates
4. Reconstruct HTLC state from monitors
5. Reconstruct claimable payments
6. Construct the ChannelManager
7. Replay pending claims and fail HTLCs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 3, 2026

🎉 This PR is now ready for review!
Please choose at least one reviewer by assigning them on the right bar.
If no reviewers are assigned within 10 minutes, I'll automatically assign one.
Once the first reviewer has submitted a review, a second will be assigned if required.

@joostjager joostjager marked this pull request as ready for review February 3, 2026 13:25
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.00%. Comparing base (35ab03f) to head (13a8a3f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4374   +/-   ##
=======================================
  Coverage   85.99%   86.00%           
=======================================
  Files         156      156           
  Lines      102766   102764    -2     
  Branches   102766   102764    -2     
=======================================
+ Hits        88378    88383    +5     
+ Misses      11879    11873    -6     
+ Partials     2509     2508    -1     
Flag Coverage Δ
tests 86.00% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Care to throw in any of these mentioned updates? #4332 (comment) Seems like a good opportunity

testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
};

// Step 7: Replay pending claims and fail HTLCs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience using step numbers in ldk-sample main, it's kinda annoying to have to update all of them when something changes. Maybe that's not as much of a risk here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might help a bit with navigation in this huge function. In other languages one would quickly extract methods, but in my experience that isn't always in Rust. Would you prefer that? I can try it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't really prefer extracting methods. Just wanted to point it out, we can keep the numbers

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants