Skip to content

Refactor handle_open_channel as a wrapper error handling function - #140

Closed
ariard wants to merge 1 commit into
lightningdevkit:masterfrom
ariard:error_handling_refactor
Closed

ariard wants to merge 1 commit into
lightningdevkit:masterfrom
ariard:error_handling_refactor

Conversation

@ariard

@ariard ariard commented Aug 31, 2018

Copy link
Copy Markdown

Okay, start the refactor of handle_MSG to handle our own Error message and closing the channel when needed. First try redesign, do we really want to dry up handle_MSG of HandleError so ChannelMessageHandler client doesn't have to do it by itself ?
No sure about the macro stuff, it's really moving it from peer_handler to channel_manager in some way..

@ariard

ariard commented Aug 31, 2018

Copy link
Copy Markdown
Author

Side-note: I took the opportunity to review the BOLT 2 open_channel message part, I think we're fine on the imperative part, maybe if we to follow the optional otems we can add a msg.funding_satoshis < min_chan_size { return Err }?
Lnd does this.

Comment thread src/ln/channelmanager.rs Outdated
Some(msgs::ErrorAction::IgnoreError) => {
return Err(false);
},
Some(msgs::ErrorAction::SendErrorMessage { msg: error_msg }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wait, why change the return type to Result<.., bool>? Should still be able to return the same Err object, just possibly handling the channel closure on Disconnect/SendErrorMessage first?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Was my inquiry, do we want to give back exactly the same Err object even if action is no more accurate? At first I've written return { HandleError: ...action : msgs::ErrorAction::IgnoreError } for DisconnectPeer and SendErrorMessage.
In the wrapper we just manage channel closure, not the others errors actions given back?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yea, I assume just return the same Err, since the ErrorMessage still needs to be relayed to the peer.

Comment thread src/ln/channelmanager.rs
},
Some(msgs::ErrorAction::IgnoreError) => {},
Some(msgs::ErrorAction::SendErrorMessage { msg: _ }) => {
$self.force_close_channel(&$channel_id);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Do we want a force_close i.e an unilateral close on every error case ? maybe a close_channel here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No, I think any case where we hit an ErrorMessage we'll want a full unilateral close, sadly.

That said, we do need to extend this a bit as an ErrorMessage with a channel_id of [0u8; 32] indicates we want to force-close all channels from a given node_id, not just the one.

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Taken as #147.

@TheBlueMatt TheBlueMatt closed this Sep 5, 2018
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.

2 participants