complete match for has_context_bytes

This commit is contained in:
realbigsean
2023-02-13 16:44:54 -05:00
parent fc2d07b4e3
commit ad9af6d8b1
4 changed files with 28 additions and 17 deletions

View File

@@ -408,15 +408,12 @@ impl ProtocolId {
/// Returns `true` if the given `ProtocolId` should expect `context_bytes` in the
/// beginning of the stream, else returns `false`.
pub fn has_context_bytes(&self) -> bool {
match self.version {
Version::V2 => matches!(
self.message_name,
Protocol::BlocksByRange | Protocol::BlocksByRoot
),
Version::V1 => matches!(
self.message_name,
Protocol::BlobsByRange | Protocol::BlobsByRoot
),
match self.message_name {
Protocol::BlocksByRange | Protocol::BlocksByRoot => {
!matches!(self.version, Version::V1)
}
Protocol::BlobsByRange | Protocol::BlobsByRoot | Protocol::LightClientBootstrap => true,
Protocol::Goodbye | Protocol::Ping | Protocol::Status | Protocol::MetaData => false,
}
}
}