Skip to content

HRN resolution refinement and architectural clean-up#887

Open
chuksys wants to merge 5 commits intolightningdevkit:mainfrom
chuksys:add-support-for-hrn-resolution-follow-up
Open

HRN resolution refinement and architectural clean-up#887
chuksys wants to merge 5 commits intolightningdevkit:mainfrom
chuksys:add-support-for-hrn-resolution-follow-up

Conversation

@chuksys
Copy link
Copy Markdown
Contributor

@chuksys chuksys commented Apr 22, 2026

Description

This is a follow-up to #630 to clean up the initial HRN resolution implementation. It focuses on improving initialization flow, reducing memory indirection, and fixing minor documentation bugs.

Changes

  • Initialization: Replaced the peer_manager_hook (Mutex/Option) with a deferred Weak pointer registration to resolve circular dependencies safely and efficiently.

  • Performance: Switched to ok_or_else in DNS setup to ensure error logging/string formatting only occurs on failure.

  • Type Cleanup: Removed redundant Arc wrapping around HRNResolver and implemented Clone for the enum to simplify passing it by value.

  • Docs: Corrected the default value description for resolution_config and realigned the configuration defaults table.

  • Tests: Cleaned up variable naming in the set_test_offer helper.

Fixes #883

Refactors the circular dependency between the HRNResolver and the
PeerManager during the Node initialization process.

Changes:
- Removed the `peer_manager_hook` Mutex/Option pattern used to
  bridge the initialization gap.
- Replaced the global initialization hook with a local deferred
  registration pattern using `Arc::downgrade` after the PeerManager
  is constructed.
- Optimized `post_queue_action` by utilizing a Weak pointer upgrade
  instead of locking a Mutex on every call.

This change improves performance for HRN resolution events and
simplifies the builder logic by making the circular dependency
resolution explicit and local to the builder function.
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 22, 2026

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot ldk-reviews-bot requested a review from tnull April 22, 2026 16:11
chuksys added 4 commits April 22, 2026 17:46
Streamlines the storage and passing of HRNResolver by holding it by
value in the Node and UnifiedPayment structs.

Changes:
- Removed the outer Arc wrapper around HRNResolver in Node and
  UnifiedPayment.
- Implemented Clone for HRNResolver to facilitate easy sharing of
  the internal Arcs.
- Updated UnifiedPayment method calls to pass HRNResolver by
  reference instead of using .as_ref() on an outer Arc.

Since HRNResolver variants already contain internal Arcs, the outer
Arc was redundant and added unnecessary memory indirection.
Optimizes the DNS resolver setup by deferring log execution until an
actual failure occurs.

Changes:
- Replaced `ok_or` with `ok_or_else` when resolving DNS server
  addresses.
  evaluation and unnecessary string formatting on successful builds.

This ensures that logging overhead and string interpolation are only
incurred during error states, rather than being evaluated on every
successful initialization.
Updates the documentation in config.rs for better accuracy and 
readability.

Changes:
- Corrected the description of HRN resolution_config from 'Enabled' 
  to 'Disabled' to align with the actual default value of false.
- Realigned the Config defaults table to accommodate longer 
  type names and improve Markdown rendering.

These changes are strictly documentation-focused and do not 
alter any runtime behavior.
Cleans up the set_test_offer method by removing the underscore from
the offer parameter name.

Changes:
- Renamed `_offer` to `offer` to reflect that the variable is
  actively used within the method body.
- Ensures the code adheres to standard Rust naming conventions
  for used variables.

This is a minor cleanup of the test-only API used for HRN
integration testing.
@chuksys chuksys force-pushed the add-support-for-hrn-resolution-follow-up branch from 7877e09 to e29ae44 Compare April 22, 2026 16:47
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.

HRN Resolution Follow-ups

2 participants