pub fn on_state_change(
        &self,
        pool: &PoolReader<'_>,
        ingress_pool: &dyn IngressPoolSelect,
    ) -> Option<BlockProposal> {
        trace!(self.log, "on_state_change");
        let my_node_id = self.replica_config.node_id;
        let (beacon, parent) = get_dependencies(pool)?;
        let height = beacon.content.height.increment();
        match self
            .membership
            .get_block_maker_rank(height, &beacon, my_node_id)
        {
            Ok(Some(rank)) => {
                if !already_proposed(pool, height, my_node_id)
                    && !self.is_better_block_proposal_available(pool, height, rank)
                    && is_time_to_make_block(
                        &self.log,
                        self.registry_client.as_ref(),
                        self.replica_config.subnet_id,
                        pool,
                        height,
                        rank,
                        self.time_source.as_ref(),
                    )
                {
                    self.propose_block(pool, ingress_pool, rank, parent)
                        .map(|proposal| {
                            debug!(
                                self.log,
                                "Make proposal {:?} {:?} {:?}",
                                proposal.content.get_hash(),
                                proposal.as_ref().payload.get_hash(),
                                proposal.as_ref().payload.as_ref()
                            );
                            self.log_block(proposal.as_ref());
                            proposal
                        })
                } else {
                    None
                }
            }
            Ok(None) => {
                // this replica is not elected as block maker this round
                None
            }
            Err(err) => {
                debug!(
                    self.log,
                    "Not proposing a block due to get_node_rank error {:?}", err
                );
                None
            }
        }
    }
/// If a block should be proposed, propose it.
If a block should be proposed, propose it.
If a block should be proposed propose it .
pub fn on_state_change(
        &self,
        pool: &PoolReader<'_>,
        ingress_pool: &dyn IngressPoolSelect,
    ) -> Option<BlockProposal> {
        trace!(self.log, "on_state_change");
        let my_node_id = self.replica_config.node_id;
        let (beacon, parent) = get_dependencies(pool)?;
        let height = beacon.content.height.increment();
        match self
            .membership
            .get_block_maker_rank(height, &beacon, my_node_id)
        {
            Ok(Some(rank)) => {
                if !already_proposed(pool, height, my_node_id)
                    && !self.is_better_block_proposal_available(pool, height, rank)
                    && is_time_to_make_block(
                        &self.log,
                        self.registry_client.as_ref(),
                        self.replica_config.subnet_id,
                        pool,
                        height,
                        rank,
                        self.time_source.as_ref(),
                    )
                {
                    self.propose_block(pool, ingress_pool, rank, parent)
                        .map(|proposal| {
                            debug!(
                                self.log,
                                "Make proposal {:?} {:?} {:?}",
                                proposal.content.get_hash(),
                                proposal.as_ref().payload.get_hash(),
                                proposal.as_ref().payload.as_ref()
                            );
                            self.log_block(proposal.as_ref());
                            proposal
                        })
                } else {
                    None
                }
            }
            Ok(None) => {
                // this replica is not elected as block maker this round
                None
            }
            Err(err) => {
                debug!(
                    self.log,
                    "Not proposing a block due to get_node_rank error {:?}", err
                );
                None
            }
        }
    }
pub fn on_state_change ( & self , pool : & PoolReader < ' _ > , ingress_pool : & dyn IngressPoolSelect , ) -> Option < BlockProposal > { trace ! ( self log " " ) ; let my_node_id = self . replica_config . node_id ; let ( beacon , parent ) = get_dependencies ( pool ) ? ; let height = beacon . content . height . increment ( ) ; match self . membership . get_block_maker_rank ( height , & beacon , my_node_id ) { Ok ( Some ( rank ) ) => { if ! already_proposed ( pool , height , my_node_id ) && ! self . is_better_block_proposal_available ( pool , height , rank ) && is_time_to_make_block ( & self . log , self . registry_client . as_ref ( ) , self . replica_config . subnet_id , pool , height , rank , self . time_source . as_ref ( ) , ) { self . propose_block ( pool , ingress_pool , rank , parent ) . map ( | proposal | { debug ! ( self log " " proposal content get_hash ( ) proposal as_ref ( ) payload get_hash ( ) proposal as_ref ( ) payload as_ref ( ) ) ; self . log_block ( proposal . as_ref ( ) ) ; proposal } ) } else { None } } Ok ( None ) => { // this replica is not elected as block maker this round None } Err ( err ) => { debug ! ( self log " " err ) ; None } } }
If a block should be proposed, propose it.
If a block should be proposed propose it .
&self
pool
&PoolReader<'_>
ingress_pool
&dyn IngressPoolSelect
&self
pool
&PoolReader<'_>
ingress_pool
&dyn IngressPoolSelect