Skip to content

Refactor handle_open_channel as a wrapper error handling function #140

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

Closed

Conversation

ariard
Copy link

@ariard ariard commented Aug 31, 2018

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
Copy link
Author

ariard commented Aug 31, 2018

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.

Some(msgs::ErrorAction::IgnoreError) => {
return Err(false);
},
Some(msgs::ErrorAction::SendErrorMessage { msg: error_msg }) => {
Copy link
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
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
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.

@ariard ariard force-pushed the error_handling_refactor branch from 567afe5 to 1653afb Compare September 1, 2018 00:42
},
Some(msgs::ErrorAction::IgnoreError) => {},
Some(msgs::ErrorAction::SendErrorMessage { msg: _ }) => {
$self.force_close_channel(&$channel_id);
Copy link
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
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
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