From bb026332ef38690851d114da4eeebfcdb96db0ef Mon Sep 17 00:00:00 2001 From: xdustinface Date: Mon, 4 May 2026 11:38:38 +1000 Subject: [PATCH] refactor(dash-spv): drop unreachable `WouldBlock`/`TimedOut` Tokio's `AsyncReadExt::read` consumes `WouldBlock` inside the runtime, so the future never resolves with that error kind. Read timeouts are imposed via `tokio::time::timeout(..)` and surface as `Elapsed`, not `io::Error::TimedOut`. The four `match` blocks in `Peer::receive_message`'s framing loop kept arms for both kinds, all of which were dead code. Drop the eight unreachable arms. The remaining `Ok(0)`, `Ok(_)`, `ConnectionAborted`/`ConnectionReset`, and catch-all `Err(e)` arms continue to surface real errors, with the catch-all converting any unanticipated `io::Error` into `NetworkError::ConnectionFailed` rather than silently masking it. --- dash-spv/src/network/peer.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/dash-spv/src/network/peer.rs b/dash-spv/src/network/peer.rs index beec9cfff..2966ac52d 100644 --- a/dash-spv/src/network/peer.rs +++ b/dash-spv/src/network/peer.rs @@ -393,12 +393,6 @@ impl Peer { return Err(NetworkError::PeerDisconnected); } Ok(_) => {} - Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { - return Ok(None); - } - Err(ref e) if e.kind() == std::io::ErrorKind::TimedOut => { - return Ok(None); - } Err(ref e) if e.kind() == std::io::ErrorKind::ConnectionAborted || e.kind() == std::io::ErrorKind::ConnectionReset => @@ -455,12 +449,6 @@ impl Peer { return Err(NetworkError::PeerDisconnected); } Ok(_) => {} - Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { - return Ok(None); - } - Err(ref e) if e.kind() == std::io::ErrorKind::TimedOut => { - return Ok(None); - } Err(e) => { return Err(NetworkError::ConnectionFailed(format!( "Read failed: {}", @@ -480,12 +468,6 @@ impl Peer { return Err(NetworkError::PeerDisconnected); } Ok(_) => {} - Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { - return Ok(None); - } - Err(ref e) if e.kind() == std::io::ErrorKind::TimedOut => { - return Ok(None); - } Err(e) => { return Err(NetworkError::ConnectionFailed(format!( "Read failed: {}", @@ -534,12 +516,6 @@ impl Peer { return Err(NetworkError::PeerDisconnected); } Ok(_) => {} - Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { - return Ok(None); - } - Err(ref e) if e.kind() == std::io::ErrorKind::TimedOut => { - return Ok(None); - } Err(e) => { return Err(NetworkError::ConnectionFailed(format!( "Read failed: {}",