fn request_new_block(
        &mut self,
        state: &State<C>,
        instance_id: C::InstanceId,
        timestamp: Timestamp,
    ) -> Option<Effect<C>> {
        if let Some((prop_context, _)) = self.next_proposal.take() {
            warn!(?prop_context, "no proposal received; requesting new one");
        }
        let panorama = self.panorama_at(state, timestamp);
        let maybe_parent_hash = state.fork_choice(&panorama);
        // If the parent is a terminal block, just create a unit without a new block.
        if maybe_parent_hash.map_or(false, |hash| state.is_terminal_block(hash)) {
            return self
                .new_unit(panorama, timestamp, None, state, instance_id)
                .map(|proposal_unit| Effect::NewVertex(ValidVertex(Vertex::Unit(proposal_unit))));
        }
        // Otherwise we need to request a new consensus value to propose.
        let ancestor_values = match maybe_parent_hash {
            None => vec![],
            Some(parent_hash) => iter::once(parent_hash)
                .chain(state.ancestor_hashes(parent_hash))
                .map(|bhash| state.block(bhash).value.clone())
                .collect(),
        };
        let block_context = BlockContext::new(timestamp, ancestor_values);
        self.next_proposal = Some((block_context.clone(), panorama));
        Some(Effect::RequestNewBlock(block_context))
    }
/// Returns an effect to request a consensus value for a block to propose.
///
/// If we are already waiting for a consensus value, `None` is returned instead.
/// If the new value would come after a terminal block, the proposal is made immediately, and
/// without a value.
Returns an effect to request a consensus value for a block to propose.
If we are already waiting for a consensus value, `None` is returned instead.
If the new value would come after a terminal block, the proposal is made immediately, and
without a value.
Returns an effect to request a consensus value for a block to propose . If we are already waiting for a consensus value ` None ` is returned instead . If the new value would come after a terminal block the proposal is made immediately and without a value .
fn request_new_block(
        &mut self,
        state: &State<C>,
        instance_id: C::InstanceId,
        timestamp: Timestamp,
    ) -> Option<Effect<C>> {
        if let Some((prop_context, _)) = self.next_proposal.take() {
            warn!(?prop_context, "no proposal received; requesting new one");
        }
        let panorama = self.panorama_at(state, timestamp);
        let maybe_parent_hash = state.fork_choice(&panorama);
        // If the parent is a terminal block, just create a unit without a new block.
        if maybe_parent_hash.map_or(false, |hash| state.is_terminal_block(hash)) {
            return self
                .new_unit(panorama, timestamp, None, state, instance_id)
                .map(|proposal_unit| Effect::NewVertex(ValidVertex(Vertex::Unit(proposal_unit))));
        }
        // Otherwise we need to request a new consensus value to propose.
        let ancestor_values = match maybe_parent_hash {
            None => vec![],
            Some(parent_hash) => iter::once(parent_hash)
                .chain(state.ancestor_hashes(parent_hash))
                .map(|bhash| state.block(bhash).value.clone())
                .collect(),
        };
        let block_context = BlockContext::new(timestamp, ancestor_values);
        self.next_proposal = Some((block_context.clone(), panorama));
        Some(Effect::RequestNewBlock(block_context))
    }
fn request_new_block ( & mut self , state : & State < C > , instance_id : C :: InstanceId , timestamp : Timestamp , ) -> Option < Effect < C > > { if let Some ( ( prop_context , _ ) ) = self . next_proposal . take ( ) { warn ! ( prop_context " " ) ; } let panorama = self . panorama_at ( state , timestamp ) ; let maybe_parent_hash = state . fork_choice ( & panorama ) ; // If the parent is a terminal block, just create a unit without a new block. if maybe_parent_hash . map_or ( false , | hash | state . is_terminal_block ( hash ) ) { return self . new_unit ( panorama , timestamp , None , state , instance_id ) . map ( | proposal_unit | Effect :: NewVertex ( ValidVertex ( Vertex :: Unit ( proposal_unit ) ) ) ) ; } // Otherwise we need to request a new consensus value to propose. let ancestor_values = match maybe_parent_hash { None => vec ! [ ] , Some ( parent_hash ) => iter :: once ( parent_hash ) . chain ( state . ancestor_hashes ( parent_hash ) ) . map ( | bhash | state . block ( bhash ) . value . clone ( ) ) . collect ( ) , } ; let block_context = BlockContext :: new ( timestamp , ancestor_values ) ; self . next_proposal = Some ( ( block_context . clone ( ) , panorama ) ) ; Some ( Effect :: RequestNewBlock ( block_context ) ) }
Returns an effect to request a consensus value for a block to propose.
Returns an effect to request a consensus value for a block to propose .
&mut self
state
&State<C>
instance_id
C::InstanceId
timestamp
Timestamp
&mut self
state
&State<C>
instance_id
C::InstanceId
timestamp
Timestamp