[question] protocols/plaintext: How to use plaintext1 with builder pattern #1277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling
Transport::upgrade
one retrieves acore::transport::upgrade::Builder
. Callingauthenticate
on thisBuilder
requires the
InboundUpgrade::Output
andOutboundUprade::Output
implementation of the passed struct to be a tuple of
(ConnectionInfo, AsyncRead + AsyncWrite)
.One can not use the above builder pattern upgrade with
libp2p_plaintext::Plaintext1
, given that itsInboundUpgrade
andOutboundUpgrade
don't define a tuple as theirOutput
, but just return theplain
Negotiated<C>
. In addition, given thatPlaintext1
is just a simplewrapper around
Negotiated<C>
it is not aware of the identity of the otherside, and can thus not fulfill the
ConnectionInfo
trait.Plaintext2
does a full handshake to retrieve the PeerId of the other side tosatisfy the
ConnectionInfo
trait.This patch makes
Plaintext1
simply return a random PeerId. Whether this is avalid solution is questionable. It rather serves the purpose of showcasing the
issue.
What is the correct way of upgrading a transport with
Plaintext1
?Relates to #1240.