fn create_terminal_block_data(
        bhash: &C::Hash,
        unit: &Unit<C>,
        highway: &Highway<C>,
    ) -> TerminalBlockData<C> {
        // Safe to unwrap: Index exists, since we have units from them.
        let to_id = |vidx: ValidatorIndex| highway.validators().id(vidx).unwrap().clone();
        let state = highway.state();

        // Compute the rewards, and replace each validator index with the validator ID.
        let rewards = rewards::compute_rewards(state, bhash);
        let rewards_iter = rewards.enumerate();
        let rewards = rewards_iter.map(|(vidx, r)| (to_id(vidx), *r)).collect();

        // Report inactive validators, but only if they had sufficient time to create a unit, i.e.
        // if at least one maximum-length round passed between the first and last block.
        // Safe to unwrap: Ancestor at height 0 always exists.
        let first_bhash = state.find_ancestor_proposal(bhash, 0).unwrap();
        let sufficient_time_for_activity =
            unit.timestamp >= state.unit(first_bhash).timestamp + state.params().max_round_length();
        let inactive_validators = if sufficient_time_for_activity {
            unit.panorama.iter_none().map(to_id).collect()
        } else {
            Vec::new()
        };

        TerminalBlockData {
            rewards,
            inactive_validators,
        }
    }
/// Creates the information for the terminal block: which validators were inactive, and how
/// rewards should be distributed.
Creates the information for the terminal block: which validators were inactive, and how
rewards should be distributed.
Creates the information for the terminal block : which validators were inactive and how rewards should be distributed .
fn create_terminal_block_data(
        bhash: &C::Hash,
        unit: &Unit<C>,
        highway: &Highway<C>,
    ) -> TerminalBlockData<C> {
        // Safe to unwrap: Index exists, since we have units from them.
        let to_id = |vidx: ValidatorIndex| highway.validators().id(vidx).unwrap().clone();
        let state = highway.state();
        // Compute the rewards, and replace each validator index with the validator ID.
        let rewards = rewards::compute_rewards(state, bhash);
        let rewards_iter = rewards.enumerate();
        let rewards = rewards_iter.map(|(vidx, r)| (to_id(vidx), *r)).collect();
        // Report inactive validators, but only if they had sufficient time to create a unit, i.e.
        // if at least one maximum-length round passed between the first and last block.
        // Safe to unwrap: Ancestor at height 0 always exists.
        let first_bhash = state.find_ancestor_proposal(bhash, 0).unwrap();
        let sufficient_time_for_activity =
            unit.timestamp >= state.unit(first_bhash).timestamp + state.params().max_round_length();
        let inactive_validators = if sufficient_time_for_activity {
            unit.panorama.iter_none().map(to_id).collect()
        } else {
            Vec::new()
        };
        TerminalBlockData {
            rewards,
            inactive_validators,
        }
    }
fn create_terminal_block_data ( bhash : & C :: Hash , unit : & Unit < C > , highway : & Highway < C > , ) -> TerminalBlockData < C > { // Safe to unwrap: Index exists, since we have units from them. let to_id = | vidx : ValidatorIndex | highway . validators ( ) . id ( vidx ) . unwrap ( ) . clone ( ) ; let state = highway . state ( ) ; // Compute the rewards, and replace each validator index with the validator ID. let rewards = rewards :: compute_rewards ( state , bhash ) ; let rewards_iter = rewards . enumerate ( ) ; let rewards = rewards_iter . map ( | ( vidx , r ) | ( to_id ( vidx ) , * r ) ) . collect ( ) ; // Report inactive validators, but only if they had sufficient time to create a unit, i.e. // if at least one maximum-length round passed between the first and last block. // Safe to unwrap: Ancestor at height 0 always exists. let first_bhash = state . find_ancestor_proposal ( bhash , 0 ) . unwrap ( ) ; let sufficient_time_for_activity = unit . timestamp >= state . unit ( first_bhash ) . timestamp + state . params ( ) . max_round_length ( ) ; let inactive_validators = if sufficient_time_for_activity { unit . panorama . iter_none ( ) . map ( to_id ) . collect ( ) } else { Vec :: new ( ) } ; TerminalBlockData { rewards , inactive_validators , } }
Creates the information for the terminal block: which validators were inactive, and how
rewards should be distributed.
Creates the information for the terminal block : which validators were inactive and how rewards should be distributed .
bhash
&C::Hash
unit
&Unit<C>
highway
&Highway<C>
bhash
&C::Hash
unit
&Unit<C>
highway
&Highway<C>