rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

protocols/noise: Inline `handshake` functions into upgrade traits

Open thomaseizinger opened this issue 3 years ago • 0 comments

Description

This fell out of https://github.com/libp2p/rust-libp2p/pull/2903. It removes a layer of indirection by inlining the various handshake functions into the respective upgrade traits. This should hopefully make it clearer, what message exchange actually happens for a particular handshake pattern.

This also removes a bit of complexity in terms of what the {send,receive}_identity functions do as several parts of it were conditional based on actually statically known state.

This is a breaking change because we make the entire handshake module private and thus prevent external users from re-using our handshake functions. However, I don't think having these public in the first place was a good move. The libp2p-noise crate specifically offers support for noise within libp2p and should not be used for noise handshakes in general.

Conveniently, this is also a net-negative in terms of code size :)

Links to any relevant issues

Open Questions

Change checklist

  • [x] I have performed a self-review of my own code
  • [x] I have made corresponding changes to the documentation
  • ~[ ] I have added tests that prove my fix is effective or that my feature works~
  • [x] A changelog entry has been made in the appropriate crates

thomaseizinger avatar Sep 16 '22 07:09 thomaseizinger