mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
fix: Returns an error if multiplex message is empty (#7314)
This commit is contained in:
@@ -166,7 +166,10 @@ impl<St> RlpxProtocolMultiplexer<St> {
|
||||
tokio::select! {
|
||||
Some(Ok(msg)) = self.inner.conn.next() => {
|
||||
// Ensure the message belongs to the primary protocol
|
||||
let offset = msg[0];
|
||||
let Some(offset) = msg.first().copied()
|
||||
else {
|
||||
return Err(P2PStreamError::EmptyProtocolMessage.into())
|
||||
};
|
||||
if let Some(cap) = self.shared_capabilities().find_by_relative_offset(offset).cloned() {
|
||||
if cap == shared_cap {
|
||||
// delegate to primary
|
||||
@@ -518,7 +521,11 @@ where
|
||||
match this.inner.conn.poll_next_unpin(cx) {
|
||||
Poll::Ready(Some(Ok(msg))) => {
|
||||
delegated = true;
|
||||
let offset = msg[0];
|
||||
let Some(offset) = msg.first().copied() else {
|
||||
return Poll::Ready(Some(Err(
|
||||
P2PStreamError::EmptyProtocolMessage.into()
|
||||
)))
|
||||
};
|
||||
// delegate the multiplexed message to the correct protocol
|
||||
if let Some(cap) =
|
||||
this.inner.conn.shared_capabilities().find_by_relative_offset(offset)
|
||||
|
||||
Reference in New Issue
Block a user