Allow 1 count block request to return 0 blocks (#5554)

* Allow 1 count block request to return 0 blocks

* Address @pawanjay176 review
This commit is contained in:
Lion - dapplion
2024-04-12 23:22:20 +09:00
committed by GitHub
parent 6bac5ce12b
commit 5fdd3b39bb
5 changed files with 63 additions and 72 deletions

View File

@@ -91,8 +91,8 @@ impl<E: EthSpec> OutboundRequest<E> {
}
/* These functions are used in the handler for stream management */
/// Number of responses expected for this request.
pub fn expected_responses(&self) -> u64 {
/// Maximum number of responses expected for this request.
pub fn max_responses(&self) -> u64 {
match self {
OutboundRequest::Status(_) => 1,
OutboundRequest::Goodbye(_) => 0,
@@ -105,6 +105,19 @@ impl<E: EthSpec> OutboundRequest<E> {
}
}
pub fn expect_exactly_one_response(&self) -> bool {
match self {
OutboundRequest::Status(_) => true,
OutboundRequest::Goodbye(_) => false,
OutboundRequest::BlocksByRange(_) => false,
OutboundRequest::BlocksByRoot(_) => false,
OutboundRequest::BlobsByRange(_) => false,
OutboundRequest::BlobsByRoot(_) => false,
OutboundRequest::Ping(_) => true,
OutboundRequest::MetaData(_) => true,
}
}
/// Gives the corresponding `SupportedProtocol` to this request.
pub fn versioned_protocol(&self) -> SupportedProtocol {
match self {