fix(net): add capacity check on ping (#558)

This commit is contained in:
Matthias Seitz
2022-12-21 14:41:14 +01:00
committed by GitHub
parent 276be27310
commit d84eb9d93c

View File

@ -339,6 +339,10 @@ where
let id = *bytes.first().ok_or(P2PStreamError::EmptyProtocolMessage)?;
match id {
_ if id == P2PMessageID::Ping as u8 => {
if this.outgoing_messages.len() > MAX_P2P_CAPACITY {
return Poll::Ready(Some(Err(P2PStreamError::SendBufferFull)))
}
tracing::trace!("Received Ping, Sending Pong");
this.send_pong();
}