/// Calculates the next expected message and signal indices for a given
/// stream, based on `state` and the subsequent `payloads`.
///
/// The next expected message index is the most recent `messages.end()` from
/// `subnet_id` in `payloads`, when that exists; or `signals_end` of the
/// outgoing `Stream` to `subnet_id` in `state`. The next expected signal
/// index is the most recent `signals_end` from `subnet_id` in `payloads`,
/// when that exists; or `messages_begin()` of the outgoing `Stream` to
/// `subnet_id` in `state`.
///
/// Returns the default value `(0, 0)` when no stream or slices from the
/// given subnet exist.
Calculates the next expected message and signal indices for a given
stream, based on `state` and the subsequent `payloads`.



Returns the default value `(0, 0)` when no stream or slices from the
given subnet exist.
Calculates the next expected message and signal indices for a given stream based on ` state ` and the subsequent ` payloads ` . Returns the default value ` ( 0 0 ) ` when no stream or slices from the given subnet exist .
fn expected_indices_for_stream(
        &self,
        subnet_id: SubnetId,
        state: &ReplicatedState,
        payloads: &[&XNetPayload],
    ) -> ExpectedIndices {
        // Stream slices may contain signals only (and no message index). Remember the
        // first `signals_end` we encounter (if any) and return it as the expected
        // signal index, if present.
        let mut most_recent_signal_index = None;
        // Look for the most recent stream slice from `subnet_id`, if any.
        for payload in payloads.iter() {
            if let Some(certified_stream) = payload.stream_slices.get(&subnet_id) {
                let slice = self
                    .certified_stream_store
                    .decode_valid_certified_stream_slice(certified_stream)
                    .expect("failed to decode past certified stream");
                if let Some(messages) = slice.messages() {
                    return ExpectedIndices {
                        message_index: messages.end(),
                        signal_index: most_recent_signal_index
                            .unwrap_or_else(|| slice.header().signals_end),
                    };
                }
                most_recent_signal_index.get_or_insert_with(|| slice.header().signals_end);
            }
        }
        // No stream slice from `subnet_id` in `payloads`, look in `state`.
        state
            .streams()
            .get(&subnet_id)
            .map(|stream| ExpectedIndices {
                message_index: stream.signals_end(),
                signal_index: most_recent_signal_index.unwrap_or_else(|| stream.messages_begin()),
            })
            .unwrap_or_default()
    }
fn expected_indices_for_stream ( & self , subnet_id : SubnetId , state : & ReplicatedState , payloads : & [ & XNetPayload ] , ) -> ExpectedIndices { // Stream slices may contain signals only (and no message index). Remember the // first `signals_end` we encounter (if any) and return it as the expected // signal index, if present. let mut most_recent_signal_index = None ; // Look for the most recent stream slice from `subnet_id`, if any. for payload in payloads . iter ( ) { if let Some ( certified_stream ) = payload . stream_slices . get ( & subnet_id ) { let slice = self . certified_stream_store . decode_valid_certified_stream_slice ( certified_stream ) . expect ( " " ) ; if let Some ( messages ) = slice . messages ( ) { return ExpectedIndices { message_index : messages . end ( ) , signal_index : most_recent_signal_index . unwrap_or_else ( | | slice . header ( ) . signals_end ) , } ; } most_recent_signal_index . get_or_insert_with ( | | slice . header ( ) . signals_end ) ; } } // No stream slice from `subnet_id` in `payloads`, look in `state`. state . streams ( ) . get ( & subnet_id ) . map ( | stream | ExpectedIndices { message_index : stream . signals_end ( ) , signal_index : most_recent_signal_index . unwrap_or_else ( | | stream . messages_begin ( ) ) , } ) . unwrap_or_default ( ) }
Calculates the next expected message and signal indices for a given
stream, based on `state` and the subsequent `payloads`.
Calculates the next expected message and signal indices for a given stream based on ` state ` and the subsequent ` payloads ` .
&self
subnet_id
SubnetId
state
&ReplicatedState
payloads
&[&XNetPayload]