Skip to content

Commit

Permalink
refactor: explicitly list all message types when specifying tier (#12634
Browse files Browse the repository at this point in the history
)

This is a follow-up to [this
comment](#12632 (review)).
  • Loading branch information
pugachAG authored Dec 17, 2024
1 parent c4e8d97 commit f867ea7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion chain/network/src/peer_manager/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl tcp::Tier {

pub(crate) fn is_allowed_routed(self, body: &RoutedMessageBody) -> bool {
match body {
// T1
RoutedMessageBody::BlockApproval(..)
| RoutedMessageBody::VersionedChunkEndorsement(..)
| RoutedMessageBody::PartialEncodedStateWitness(..)
Expand All @@ -57,7 +58,32 @@ impl tcp::Tier {
| RoutedMessageBody::ChunkContractAccesses(_)
| RoutedMessageBody::ContractCodeRequest(_)
| RoutedMessageBody::ContractCodeResponse(_) => true,
_ => self == tcp::Tier::T2,
// Rest
RoutedMessageBody::ForwardTx(..)
| RoutedMessageBody::TxStatusRequest(..)
| RoutedMessageBody::TxStatusResponse(..)
| RoutedMessageBody::PartialEncodedChunkRequest(..)
| RoutedMessageBody::PartialEncodedChunkResponse(..)
| RoutedMessageBody::Ping(..)
| RoutedMessageBody::Pong(..)
| RoutedMessageBody::PartialEncodedChunkForward(..)
| RoutedMessageBody::ChunkStateWitnessAck(..)
| RoutedMessageBody::StatePartRequest(..)
| RoutedMessageBody::PartialEncodedContractDeploys(..) => self == tcp::Tier::T2,
// Deprecated
RoutedMessageBody::_UnusedQueryRequest
| RoutedMessageBody::_UnusedQueryResponse
| RoutedMessageBody::_UnusedReceiptOutcomeRequest(..)
| RoutedMessageBody::_UnusedReceiptOutcomeResponse
| RoutedMessageBody::_UnusedStateRequestHeader
| RoutedMessageBody::_UnusedStateRequestPart
| RoutedMessageBody::_UnusedStateResponse
| RoutedMessageBody::_UnusedPartialEncodedChunk
| RoutedMessageBody::_UnusedVersionedStateResponse
| RoutedMessageBody::_UnusedChunkStateWitness
| RoutedMessageBody::_UnusedChunkEndorsement
| RoutedMessageBody::_UnusedEpochSyncRequest
| RoutedMessageBody::_UnusedEpochSyncResponse(..) => unreachable!(),
}
}
}
Expand Down

0 comments on commit f867ea7

Please sign in to comment.