-
Notifications
You must be signed in to change notification settings - Fork 412
Channel cleanups #152
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
Channel cleanups #152
Conversation
Because we don't have an HTLCState for update_add_htlc-generated-but-not-yet-commitment_signed to simplify the mess of HTLCState match arms, any time a Channel::send_htlc call returns Ok(Some(_)) we MUST call commitment_signed and it MUST return success (or close the channel). We mention this in the docs and panic if its not met in ChannelManager (which lets the fuzz tester check this).
This was redundant and was included because the HTLC still needed to be monitored, but that happens in ChannelMonitor, so there is no need for it in Channel itself.
match $res { | ||
Ok(key) => key, | ||
//TODO: make the error a parameter | ||
Err(_) => return Err(HandleError{err: $err, action: Some(msgs::ErrorAction::DisconnectPeer{ msg: None })}) | ||
Err(_) => return Err(HandleError {err: $err, action: Some(msgs::ErrorAction::SendErrorMessage {msg: msgs::ErrorMessage {channel_id: $chan_id, data: $err.to_string()}})}) |
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.
One more #153 case isn't it ?
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.
Yea, I'm anticipating the fix for #153 is to just remove the distinction, have a general ChannelError type, then convert it to a HandleError in ChannelManager. That would simplify some of the Internal error awkwardness right now anyway.
} else if let &Some(msgs::ErrorAction::SendErrorMessage{msg: ref _err_msg}) = &e.action { | ||
} else { | ||
panic!("Stated return value requirements in send_commitment() were not met"); | ||
} | ||
//TODO: Handle...this is bad! |
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.
seems all kind of errors are covered by the last else, so TODO can disappear?
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.
Heh, the ifs/panic is just to give the fuzz tester something to attack. The actually handling still has to happen.
Concept ACK, but to be honest doesn't have (yet) all the subtilities of HTLCState in head! |
Some simple cleanups I came across while starting work on #138.