Skip to content

Refactor ChannelManager handle functions into a Channel-closing macro - #147

Merged
TheBlueMatt merged 7 commits into
lightningdevkit:masterfrom
TheBlueMatt:2018-09-channelmanager-err-macro
Sep 5, 2018
Merged

TheBlueMatt merged 7 commits into
lightningdevkit:masterfrom
TheBlueMatt:2018-09-channelmanager-err-macro

Conversation

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

This is a rebase/rewrite/extension of #140 since it was missing some stuff and I wanted to get the jump on using it to move announcement_signatures handling into it so we can finally close up BOLT 7 handling.

TheBlueMatt and others added 2 commits September 4, 2018 20:19
Original macro is from Antoine Riard <ariard@student.42.fr>,
the error type and additional mappings are from
Matt Corallo <git@bluematt.me>
Original version is from Antoine Riard <ariard@student.42.fr>,
the error type and some return type fixes are from
Matt Corallo <git@bluematt.me>
@TheBlueMatt TheBlueMatt changed the title 2018 09 channelmanager err macro Refactor ChannelManager handle functions into a Channel-closing macro Sep 5, 2018
They are all just "its too early/late to get an announcement"
errors so simply ignoring them and not sending an announce is fine
Because we've separated out channel closure from ErrorMessage
returning we can return error messages in a few additional cases,
like if the peer sent us a message for a channel they didn't own.
@TheBlueMatt
TheBlueMatt force-pushed the 2018-09-channelmanager-err-macro branch from 500582e to a71abac Compare September 5, 2018 00:28
Comment thread src/ln/channelmanager.rs
err: msgs::HandleError,
needs_channel_force_close: bool,
}
impl MsgHandleErrInternal {

@ariard ariard Sep 5, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmmm having a builder is great to simplify errors filling but I think it's force us to specify a method for each case as a71abac shows it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, maybe, though I also don't want to have ErrBuilder::new().msg().action().needs_close() every time we want to return an Err cause then we spend all our charachters on a line on error handling :/. Not sure if there's a great solution here, really, but I'm open to patches to play around with it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Okay, c-lightning doesn't have a concept of general handle error like us.
Still not delighted by this design, but don't see better for now so will go ahead with this for channel refactoring.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Alright, well nothing stopping us from cleaning up things with macros or flattening errors in a future PR.

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