fn new_unit(
        &mut self,
        panorama: Panorama<C>,
        timestamp: Timestamp,
        value: Option<C::ConsensusValue>,
        state: &State<C>,
        instance_id: C::InstanceId,
    ) -> Option<SignedWireUnit<C>> {
        if value.is_none() && !panorama.has_correct() {
            return None; // Wait for the first proposal before creating a unit without a value.
        }
        if !self.can_vote(state) {
            info!(?self.own_last_unit, "not voting - last own unit unknown");
            return None;
        }
        if let Some((prop_context, _)) = self.next_proposal.take() {
            warn!(?prop_context, "canceling proposal due to unit");
        }
        for hash in panorama.iter_correct_hashes() {
            if timestamp < state.unit(hash).timestamp {
                error!(
                    %timestamp, justification_timestamp = %state.unit(hash).timestamp,
                    "canceling unit creation because of outdated timestamp"
                );
                return None;
            }
        }
        if panorama[self.vidx] != state.panorama()[self.vidx] {
            error!(
                ?panorama,
                "panorama for new unit would be equivocation; canceling unit creation"
            );
            return None;
        }
        let seq_number = panorama.next_seq_num(state, self.vidx);
        let endorsed = state.seen_endorsed(&panorama);
        let hwunit = WireUnit {
            panorama,
            creator: self.vidx,
            instance_id,
            value,
            seq_number,
            timestamp,
            round_exp: self.round_exp(state, timestamp),
            endorsed,
        }
        .into_hashed();
        let swunit = SignedWireUnit::new(hwunit, &self.secret);
        write_last_unit(&self.unit_file, swunit.clone()).unwrap_or_else(|err| {
            panic!(
                "should successfully write unit's hash to {:?}, got {:?}",
                self.unit_file, err
            )
        });
        Some(swunit)
    }
/// Returns a new unit with the given data, and the correct sequence number.
///
/// Returns `None` if it's not possible to create a valid unit with the given panorama.
Returns a new unit with the given data, and the correct sequence number.
Returns `None` if it's not possible to create a valid unit with the given panorama.
Returns a new unit with the given data and the correct sequence number . Returns ` None ` if it ' s not possible to create a valid unit with the given panorama .
fn new_unit(
        &mut self,
        panorama: Panorama<C>,
        timestamp: Timestamp,
        value: Option<C::ConsensusValue>,
        state: &State<C>,
        instance_id: C::InstanceId,
    ) -> Option<SignedWireUnit<C>> {
        if value.is_none() && !panorama.has_correct() {
            return None; // Wait for the first proposal before creating a unit without a value.
        }
        if !self.can_vote(state) {
            info!(?self.own_last_unit, "not voting - last own unit unknown");
            return None;
        }
        if let Some((prop_context, _)) = self.next_proposal.take() {
            warn!(?prop_context, "canceling proposal due to unit");
        }
        for hash in panorama.iter_correct_hashes() {
            if timestamp < state.unit(hash).timestamp {
                error!(
                    %timestamp, justification_timestamp = %state.unit(hash).timestamp,
                    "canceling unit creation because of outdated timestamp"
                );
                return None;
            }
        }
        if panorama[self.vidx] != state.panorama()[self.vidx] {
            error!(
                ?panorama,
                "panorama for new unit would be equivocation; canceling unit creation"
            );
            return None;
        }
        let seq_number = panorama.next_seq_num(state, self.vidx);
        let endorsed = state.seen_endorsed(&panorama);
        let hwunit = WireUnit {
            panorama,
            creator: self.vidx,
            instance_id,
            value,
            seq_number,
            timestamp,
            round_exp: self.round_exp(state, timestamp),
            endorsed,
        }
        .into_hashed();
        let swunit = SignedWireUnit::new(hwunit, &self.secret);
        write_last_unit(&self.unit_file, swunit.clone()).unwrap_or_else(|err| {
            panic!(
                "should successfully write unit's hash to {:?}, got {:?}",
                self.unit_file, err
            )
        });
        Some(swunit)
    }
fn new_unit ( & mut self , panorama : Panorama < C > , timestamp : Timestamp , value : Option < C :: ConsensusValue > , state : & State < C > , instance_id : C :: InstanceId , ) -> Option < SignedWireUnit < C > > { if value . is_none ( ) && ! panorama . has_correct ( ) { return None ; // Wait for the first proposal before creating a unit without a value. } if ! self . can_vote ( state ) { info ! ( self own_last_unit " " ) ; return None ; } if let Some ( ( prop_context , _ ) ) = self . next_proposal . take ( ) { warn ! ( prop_context " " ) ; } for hash in panorama . iter_correct_hashes ( ) { if timestamp < state . unit ( hash ) . timestamp { error ! ( timestamp justification_timestamp state unit ( hash ) timestamp " " ) ; return None ; } } if panorama [ self . vidx ] != state . panorama ( ) [ self . vidx ] { error ! ( panorama " " ) ; return None ; } let seq_number = panorama . next_seq_num ( state , self . vidx ) ; let endorsed = state . seen_endorsed ( & panorama ) ; let hwunit = WireUnit { panorama , creator : self . vidx , instance_id , value , seq_number , timestamp , round_exp : self . round_exp ( state , timestamp ) , endorsed , } . into_hashed ( ) ; let swunit = SignedWireUnit :: new ( hwunit , & self . secret ) ; write_last_unit ( & self . unit_file , swunit . clone ( ) ) . unwrap_or_else ( | err | { panic ! ( " " self unit_file err ) } ) ; Some ( swunit ) }
Returns a new unit with the given data, and the correct sequence number.
Returns a new unit with the given data and the correct sequence number .
&mut self
panorama
Panorama<C>
timestamp
Timestamp
value
Option<C::ConsensusValue>
state
&State<C>
instance_id
C::InstanceId
&mut self
panorama
Panorama<C>
timestamp
Timestamp
value
Option<C::ConsensusValue>
state
&State<C>
instance_id
C::InstanceId