Skip to content

Extract wire message handling into a method. #629

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

Merged

Conversation

arik-so
Copy link
Contributor

@arik-so arik-so commented May 22, 2020

This is a response to splitting #585 into smaller components. This extraction should allow the subsequent creation of a trait for all message handling, thereby enabling more flexibility in the state machine, particularly for bindings.

@jkczyz jkczyz self-requested a review May 22, 2020 20:26
@arik-so arik-so force-pushed the message_handling_extraction branch from 2da6b77 to 9c6d5ea Compare May 26, 2020 16:40
@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #629 into master will decrease coverage by 0.01%.
The diff coverage is 38.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files          35       35              
  Lines       20918    20942      +24     
==========================================
+ Hits        19090    19109      +19     
- Misses       1828     1833       +5     
Impacted Files Coverage Δ
lightning/src/ln/peer_handler.rs 55.00% <38.93%> (+0.85%) ⬆️
lightning/src/ln/functional_tests.rs 97.11% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f08d610...3838c04. Read the comment docs.

Comment on lines 206 to 216
enum MessageHandlingResult {
Ok,
PeerHandleError(PeerHandleError),
LightningError(LightningError),
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use Result with an enum error instead of rolling a custom result type? You should be able to match on complex patterns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, that's a much better approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(done)

@valentinewallace
Copy link
Contributor

Second all of Jeff's comments but this looks like a nice change. Might appreciate a high-level comment with what the end goal trait looks like to make sure I understand correctly what you're going for -- and my understanding is that the PeerHandler will have a pointer to an implementer of this trait?

@arik-so arik-so force-pushed the message_handling_extraction branch from 9c6d5ea to 73b379f Compare June 1, 2020 19:36
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Thanks for the update -- looks good! Just some minor stuff

return Err(PeerHandleError{ no_connection_possible: false }.into());
}

log_info!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems "unknown local flags" and "unknown global" flags could use some clarification, since they're the same thing bits here? Maybe just a comment if there's good reasoning, else rename one more descriptively and get rid of the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rephrased this

@arik-so arik-so force-pushed the message_handling_extraction branch from 73b379f to bf11673 Compare June 1, 2020 21:31
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

LGTM. Can you rebase?

This is a response to splitting lightningdevkit#585 into smaller components. This extraction should allow the subsequent creation of a trait for all message handling, thereby enabling more flexibility in the state machine, particularly for bindings.
@arik-so arik-so force-pushed the message_handling_extraction branch from 836c7b0 to 3838c04 Compare June 7, 2020 06:00
@TheBlueMatt TheBlueMatt merged commit 7aae6d5 into lightningdevkit:master Jun 11, 2020
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.

4 participants