-
Notifications
You must be signed in to change notification settings - Fork 413
Further decouple ChannelManager from Channel state somewhat #3539
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
Further decouple ChannelManager from Channel state somewhat #3539
Conversation
/// Should be called when the peer is disconnected. Returns true if the channel can be resumed | ||
/// when the peer reconnects (via [`Self::peer_connected_get_handshake`]). If not, the channel | ||
/// must be immediately closed. | ||
pub fn peer_disconnected_is_resumable<L: Deref>(&mut self, logger: &L) -> bool where L::Target: Logger { |
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.
How about naming this is_disconnected_peer_resumable
?
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.
Its not stateless, though, I wanted to communicate that its a "this peer has disconnected" notification, plus "should i discard the channel". Not sure how best to communicate it, this name is a bit awkward.
LGTM once the logging context is restored |
e25da14
to
2abe846
Compare
Sorry for the delay, fixed the logger issue: $ git diff-tree -U2 e25da1455 2abe8469b
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index fcc11ca05..16599f126 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -9455,6 +9455,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
// Returns whether we should remove this channel as it's just been closed.
let unblock_chan = |phase: &mut Channel<SP>, pending_msg_events: &mut Vec<MessageSendEvent>| -> Option<ShutdownResult> {
+ let logger = WithChannelContext::from(&self.logger, &phase.context(), None);
let node_id = phase.context().get_counterparty_node_id();
- if let Some(msgs) = phase.signer_maybe_unblocked(self.chain_hash, &self.logger) {
+ if let Some(msgs) = phase.signer_maybe_unblocked(self.chain_hash, &&logger) {
if let Some(msg) = msgs.open_channel {
pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
@@ -9513,7 +9514,4 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
if let Some(broadcast_tx) = msgs.signed_closing_tx {
- let channel_id = chan.context.channel_id();
- let counterparty_node_id = chan.context.get_counterparty_node_id();
- let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(channel_id), None);
log_info!(logger, "Broadcasting closing tx {}", log_tx!(broadcast_tx));
self.tx_broadcaster.broadcast_transactions(&[&broadcast_tx]); |
FYI, this will conflict with #3550. May be easier to get that in first, but either way is fine by me. |
After lightningdevkit#3513 we have a bit more encapsulation of channel logic in channel.rs with channelmanager.rs needing a bit less knowledge of which specific state a channel is in. This continues that trend slightly when unblocking the signer.
Rebased. |
2abe846
to
6852e8a
Compare
After lightningdevkit#3513 we have a bit more encapsulation of channel logic in channel.rs with channelmanager.rs needing a bit less knowledge of which specific state a channel is in. This continues that trend slightly when a peer disconnects.
After lightningdevkit#3513 we have a bit more encapsulation of channel logic in channel.rs with channelmanager.rs needing a bit less knowledge of which specific state a channel is in. This continues that trend slightly when a peer reconnects.
6852e8a
to
bece44c
Compare
Ugh, fixed the dangling link after the third commit. |
Just a few tiny followups to #3513 to keep moving towards ChannelManager caring less about the specific state the channel is in.