-
Notifications
You must be signed in to change notification settings - Fork 106
refactor(l1): spawned p2p #3164
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
Conversation
Lines of code reportTotal lines added: Detailed view
|
pub(crate) init_message: Vec<u8>, | ||
} | ||
|
||
pub(crate) async fn perform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name "perform" a bit confusing, can we add some comments on what this function does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, "perform" as in "perform handshake", a little bit confusing without context still
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... is to be used in the form handshake::perform
but will think if there's a more expressive way
pub(crate) stream: Arc<TcpStream>, | ||
} | ||
|
||
#[derive(Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this struct really need Clone? The original RLPxConnection didn't need to be cloned, also if we're clonning an 'established' connection somewhere, I'm guessing we're doing something wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as it is part of the State
of a GenServer
. We may be cloning the state, but not the connection itself (which is a single spawned
task)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a couple of questions
} | ||
|
||
impl GenServer for RLPxConnection { | ||
type CallMsg = Unused; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If we have unused here, do we need to define the empty call message struct above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, good find. Don't know why rust forgot to complain about an unused struct.
P2p connection processes are complex and error prone. Using `spawned` to clean it up and properly separate concurrency logic from business logic. **Description** Replaces the main_loop from `RLPxConnection` with a `spawned` process that handles all the messages from and to the remote peer, as well as the backend. --------- Co-authored-by: Lucas Fiegl <[email protected]> Co-authored-by: Tomás Grüner <[email protected]> Co-authored-by: Manuel Iñaki Bilbao <[email protected]> Co-authored-by: Avila Gastón <[email protected]> Co-authored-by: Ivan Litteri <[email protected]> Co-authored-by: Jeremías Salomón <[email protected]> Co-authored-by: Mario Rugiero <[email protected]> Co-authored-by: MrAzteca <[email protected]> Co-authored-by: Edgar <[email protected]> Co-authored-by: LeanSerra <[email protected]>
P2p connection processes are complex and error prone. Using `spawned` to clean it up and properly separate concurrency logic from business logic. **Description** Replaces the main_loop from `RLPxConnection` with a `spawned` process that handles all the messages from and to the remote peer, as well as the backend. --------- Co-authored-by: Lucas Fiegl <[email protected]> Co-authored-by: Tomás Grüner <[email protected]> Co-authored-by: Manuel Iñaki Bilbao <[email protected]> Co-authored-by: Avila Gastón <[email protected]> Co-authored-by: Ivan Litteri <[email protected]> Co-authored-by: Jeremías Salomón <[email protected]> Co-authored-by: Mario Rugiero <[email protected]> Co-authored-by: MrAzteca <[email protected]> Co-authored-by: Edgar <[email protected]> Co-authored-by: LeanSerra <[email protected]>
P2p connection processes are complex and error prone. Using
spawned
to clean it up and properly separate concurrency logic from business logic.Description
Replaces the main_loop from
RLPxConnection
with aspawned
process that handles all the messages from and to the remote peer, as well as the backend.