Skip to content
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

Use UnauthedEthStream pattern for creating an EthStream #160

Closed
Rjected opened this issue Nov 3, 2022 · 0 comments · Fixed by #162
Closed

Use UnauthedEthStream pattern for creating an EthStream #160

Rjected opened this issue Nov 3, 2022 · 0 comments · Fixed by #162
Labels
A-devp2p Related to the Ethereum P2P protocol C-enhancement New feature or request

Comments

@Rjected
Copy link
Member

Rjected commented Nov 3, 2022

A P2PStream is created by first constructing an UnauthedP2PStream (which wraps an underlying Stream + Sink) and awaiting on the UnauthedP2PStream::handshake method, returning a P2PStream:

let unauthed_stream = UnauthedP2PStream::new(stream);
let p2p_stream = unauthed_stream.handshake(client_hello).await.unwrap();

This ensures that all P2PStreams in use are with peers that have successfully completed the p2p handshake.

EthStream currently uses an authed flag to determine if a stream is authenticated, when instead we can take the above approach to construct an EthStream. Similar to #157, we should also return the incoming Status with the authenticated EthStream.

@Rjected Rjected added C-enhancement New feature or request A-devp2p Related to the Ethereum P2P protocol labels Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devp2p Related to the Ethereum P2P protocol C-enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant