pub fn block_msgs_for_tipset(&self, ts: &Tipset) -> Result<Vec<BlockMessages>, Error> {
        let mut applied = HashMap::new();
        let mut select_msg = |m: ChainMessage| -> Option<ChainMessage> {
            // The first match for a sender is guaranteed to have correct nonce
            // the block isn't valid otherwise.
            let entry = applied.entry(*m.from()).or_insert_with(|| m.sequence());

            if *entry != m.sequence() {
                return None;
            }

            *entry += 1;
            Some(m)
        };

        ts.blocks()
            .iter()
            .map(|b| {
                let (usm, sm) = block_messages(self.blockstore(), b)?;

                let mut messages = Vec::with_capacity(usm.len() + sm.len());
                messages.extend(
                    usm.into_iter()
                        .filter_map(|m| select_msg(ChainMessage::Unsigned(m))),
                );
                messages.extend(
                    sm.into_iter()
                        .filter_map(|m| select_msg(ChainMessage::Signed(m))),
                );

                Ok(BlockMessages {
                    miner: *b.miner_address(),
                    messages,
                    win_count: b
                        .election_proof()
                        .as_ref()
                        .map(|e| e.win_count)
                        .unwrap_or_default(),
                })
            })
            .collect()
    }
/// Retrieves block messages to be passed through the VM.
Retrieves block messages to be passed through the VM.
Retrieves block messages to be passed through the VM .
pub fn block_msgs_for_tipset(&self, ts: &Tipset) -> Result<Vec<BlockMessages>, Error> {
        let mut applied = HashMap::new();
        let mut select_msg = |m: ChainMessage| -> Option<ChainMessage> {
            // The first match for a sender is guaranteed to have correct nonce
            // the block isn't valid otherwise.
            let entry = applied.entry(*m.from()).or_insert_with(|| m.sequence());
            if *entry != m.sequence() {
                return None;
            }
            *entry += 1;
            Some(m)
        };
        ts.blocks()
            .iter()
            .map(|b| {
                let (usm, sm) = block_messages(self.blockstore(), b)?;
                let mut messages = Vec::with_capacity(usm.len() + sm.len());
                messages.extend(
                    usm.into_iter()
                        .filter_map(|m| select_msg(ChainMessage::Unsigned(m))),
                );
                messages.extend(
                    sm.into_iter()
                        .filter_map(|m| select_msg(ChainMessage::Signed(m))),
                );
                Ok(BlockMessages {
                    miner: *b.miner_address(),
                    messages,
                    win_count: b
                        .election_proof()
                        .as_ref()
                        .map(|e| e.win_count)
                        .unwrap_or_default(),
                })
            })
            .collect()
    }
pub fn block_msgs_for_tipset ( & self , ts : & Tipset ) -> Result < Vec < BlockMessages > , Error > { let mut applied = HashMap :: new ( ) ; let mut select_msg = | m : ChainMessage | -> Option < ChainMessage > { // The first match for a sender is guaranteed to have correct nonce // the block isn't valid otherwise. let entry = applied . entry ( * m . from ( ) ) . or_insert_with ( | | m . sequence ( ) ) ; if * entry != m . sequence ( ) { return None ; } * entry += 1 ; Some ( m ) } ; ts . blocks ( ) . iter ( ) . map ( | b | { let ( usm , sm ) = block_messages ( self . blockstore ( ) , b ) ? ; let mut messages = Vec :: with_capacity ( usm . len ( ) + sm . len ( ) ) ; messages . extend ( usm . into_iter ( ) . filter_map ( | m | select_msg ( ChainMessage :: Unsigned ( m ) ) ) , ) ; messages . extend ( sm . into_iter ( ) . filter_map ( | m | select_msg ( ChainMessage :: Signed ( m ) ) ) , ) ; Ok ( BlockMessages { miner : * b . miner_address ( ) , messages , win_count : b . election_proof ( ) . as_ref ( ) . map ( | e | e . win_count ) . unwrap_or_default ( ) , } ) } ) . collect ( ) }
Retrieves block messages to be passed through the VM.
Retrieves block messages to be passed through the VM .
&self
ts
&Tipset