-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: rlpx multiplexing #5413
feat: rlpx multiplexing #5413
Conversation
0e12857
to
7742793
Compare
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, the multiplexer makes sense, looking forward to easy multi-cap support!
// TODO optimize this by keeping a better index | ||
let mut lowest_satellite = None; | ||
// find the protocol with the lowest offset that is greater than the message | ||
// offset | ||
for (i, proto) in this.satellites.iter().enumerate() { | ||
let proto_offset = proto.cap.relative_message_id_offset(); | ||
if proto_offset >= offset { | ||
if let Some((_, lowest_offset)) = lowest_satellite { | ||
if proto_offset < lowest_offset { | ||
lowest_satellite = Some((i, proto_offset)); | ||
} | ||
} else { | ||
lowest_satellite = Some((i, proto_offset)); | ||
} | ||
} | ||
} | ||
|
||
if let Some((idx, lowest_offset)) = lowest_satellite { | ||
if lowest_offset < this.primary_capability.relative_message_id_offset() | ||
{ | ||
// delegate to satellite | ||
this.satellites[idx].send_raw(msg); | ||
continue | ||
} | ||
} | ||
// delegate to primary | ||
let _ = this.to_primary.send(msg); |
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, an index would be nice for this
Poll::Ready(Some(msg)) => { | ||
this.out_buffer.push_back(msg); | ||
} | ||
Poll::Ready(None) => return Poll::Ready(None), |
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.
This was confusing to me at first, but if any of the streams are closed, we
need to return Poll::Ready(None)
will merge and push smaller followups |
adds support for multiplexing rlpx protocols
this is tailored for custom protocols in reth-network
this needs several followups but should be included to unblock