-
Notifications
You must be signed in to change notification settings - Fork 38
Fix: Remove Unnecessary &mut self Requirements from LightningNode Trait #284
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
Fix: Remove Unnecessary &mut self Requirements from LightningNode Trait #284
Conversation
carlaKC
left a comment
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.
cACK, heading in the right direction 👍
elnosh
left a comment
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.
think should be good to squash
|
Small nit for when you do squash: take a look at commit structure in contributing guide - we use an odd format (historical reasons), would be nice to align with that while you're at it. |
64c2815 to
3e7ac44
Compare
carlaKC
left a comment
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.
tACK, nice cleanup 🥦
closes #264
This PR refactors the LightningNode trait and its implementations to remove unnecessary &mut self references for methods that do not mutate internal state.
Motivation
Previously, several trait methods like get_network and list_channels required &mut self, even though they only retrieved information. This requirement leaked internal implementation details—specifically, that the underlying client field required a mutable reference to make gRPC or HTTP calls.
This design was misleading and unnecessarily restricted usage of the trait, e.g. preventing multiple read-only operations from being performed concurrently on the same node.
Changes
Wrapped client fields (e.g. NodeClient, EclairClient, etc.) inside tokio::sync::Mutex.
Updated all client usages to acquire a mutable lock via let mut client = self.client.lock().await;.
Updated trait method signatures to require &self instead of &mut self where applicable.
Ensured thread-safe, concurrent-friendly behavior without sacrificing correctness or clarity.