fn handle_stream(
    subnet_id: SubnetId,
    witness_begin: Option<StreamIndex>,
    msg_begin: Option<StreamIndex>,
    msg_limit: Option<usize>,
    byte_limit: Option<usize>,
    certified_stream_store: &dyn CertifiedStreamStore,
    metrics: &XNetEndpointMetrics,
) -> Response<Body> {
    let witness_begin = witness_begin.or(msg_begin);
    match certified_stream_store.encode_certified_stream_slice(
        subnet_id,
        witness_begin,
        msg_begin,
        msg_limit,
        byte_limit,
    ) {
        Ok(stream) => {
            metrics
                .slice_payload_size
                .observe(stream.payload.len() as f64);
            observe_response_size(
                || proto_response::<_, pb::CertifiedStreamSlice>(stream),
                RESOURCE_STREAM,
                metrics,
            )
        }
        Err(EncodeStreamError::NoStreamForSubnet(_)) => no_content(),
        Err(e @ EncodeStreamError::InvalidSliceBegin { .. }) => {
            range_not_satisfiable(e.to_string())
        }
        Err(e @ EncodeStreamError::InvalidSliceIndices { .. }) => bad_request(e.to_string()),
    }
}
/// Returns a stream slice for the given subnet; or a 404 response if a stream
/// for the respective subnet does not exist.
Returns a stream slice for the given subnet; or a 404 response if a stream
for the respective subnet does not exist.
Returns a stream slice for the given subnet ; or a 404 response if a stream for the respective subnet does not exist .
fn handle_stream(
    subnet_id: SubnetId,
    witness_begin: Option<StreamIndex>,
    msg_begin: Option<StreamIndex>,
    msg_limit: Option<usize>,
    byte_limit: Option<usize>,
    certified_stream_store: &dyn CertifiedStreamStore,
    metrics: &XNetEndpointMetrics,
) -> Response<Body> {
    let witness_begin = witness_begin.or(msg_begin);
    match certified_stream_store.encode_certified_stream_slice(
        subnet_id,
        witness_begin,
        msg_begin,
        msg_limit,
        byte_limit,
    ) {
        Ok(stream) => {
            metrics
                .slice_payload_size
                .observe(stream.payload.len() as f64);
            observe_response_size(
                || proto_response::<_, pb::CertifiedStreamSlice>(stream),
                RESOURCE_STREAM,
                metrics,
            )
        }
        Err(EncodeStreamError::NoStreamForSubnet(_)) => no_content(),
        Err(e @ EncodeStreamError::InvalidSliceBegin { .. }) => {
            range_not_satisfiable(e.to_string())
        }
        Err(e @ EncodeStreamError::InvalidSliceIndices { .. }) => bad_request(e.to_string()),
    }
}
fn handle_stream ( subnet_id : SubnetId , witness_begin : Option < StreamIndex > , msg_begin : Option < StreamIndex > , msg_limit : Option < usize > , byte_limit : Option < usize > , certified_stream_store : & dyn CertifiedStreamStore , metrics : & XNetEndpointMetrics , ) -> Response < Body > { let witness_begin = witness_begin . or ( msg_begin ) ; match certified_stream_store . encode_certified_stream_slice ( subnet_id , witness_begin , msg_begin , msg_limit , byte_limit , ) { Ok ( stream ) => { metrics . slice_payload_size . observe ( stream . payload . len ( ) as f64 ) ; observe_response_size ( | | proto_response :: < _ , pb :: CertifiedStreamSlice > ( stream ) , RESOURCE_STREAM , metrics , ) } Err ( EncodeStreamError :: NoStreamForSubnet ( _ ) ) => no_content ( ) , Err ( e @ EncodeStreamError :: InvalidSliceBegin { .. } ) => { range_not_satisfiable ( e . to_string ( ) ) } Err ( e @ EncodeStreamError :: InvalidSliceIndices { .. } ) => bad_request ( e . to_string ( ) ) , } }
Returns a stream slice for the given subnet; or a 404 response if a stream
for the respective subnet does not exist.
Returns a stream slice for the given subnet ; or a 404 response if a stream for the respective subnet does not exist .
subnet_id
SubnetId
witness_begin
Option<StreamIndex>
msg_begin
Option<StreamIndex>
msg_limit
Option<usize>
byte_limit
Option<usize>
certified_stream_store
&dyn CertifiedStreamStore
metrics
&XNetEndpointMetrics
subnet_id
SubnetId
witness_begin
Option<StreamIndex>
msg_begin
Option<StreamIndex>
msg_limit
Option<usize>
byte_limit
Option<usize>
certified_stream_store
&dyn CertifiedStreamStore
metrics
&XNetEndpointMetrics