mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf(net): backoff on IO error (#633)
This commit is contained in:
@ -26,6 +26,14 @@ impl EthStreamError {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the [io::Error] if it was caused by IO
|
||||
pub fn as_io(&self) -> Option<&io::Error> {
|
||||
if let EthStreamError::P2PStreamError(P2PStreamError::Io(io)) = self {
|
||||
return Some(io)
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl From<io::Error> for EthStreamError {
|
||||
|
||||
@ -95,15 +95,15 @@ impl SessionError for EthStreamError {
|
||||
EthStreamError::P2PStreamError(P2PStreamError::HandshakeError(
|
||||
P2PHandshakeError::NoResponse
|
||||
))
|
||||
) || self
|
||||
.as_disconnected()
|
||||
.map(|reason| {
|
||||
matches!(
|
||||
reason,
|
||||
DisconnectReason::TooManyPeers | DisconnectReason::AlreadyConnected
|
||||
)
|
||||
})
|
||||
.unwrap_or_default()
|
||||
) || self.as_io().is_some() ||
|
||||
self.as_disconnected()
|
||||
.map(|reason| {
|
||||
matches!(
|
||||
reason,
|
||||
DisconnectReason::TooManyPeers | DisconnectReason::AlreadyConnected
|
||||
)
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user