pub fn reconfigure(&mut self, rc: ReconfigurationRequest) -> Result<(), ProposeErr<T>> {
        let ReconfigurationRequest {
            new_configuration,
            metadata,
        } = rc;
        info!(
            self.logger,
            "Propose reconfiguration {:?}", new_configuration
        );
        if self.stopped() {
            Err(ProposeErr::Reconfiguration(new_configuration))
        } else {
            match self.state {
                (Role::Leader, Phase::Prepare) => {
                    if self.pending_stopsign.is_none() {
                        let ss = StopSign::with(self.config_id + 1, new_configuration, metadata);
                        self.pending_stopsign = Some(ss);
                    } else {
                        return Err(ProposeErr::Reconfiguration(new_configuration));
                    }
                }
                (Role::Leader, Phase::Accept) => {
                    if !self.stopped() {
                        let ss = StopSign::with(self.config_id + 1, new_configuration, metadata);
                        self.storage
                            .set_stopsign(StopSignEntry::with(ss.clone(), false));
                        self.leader_state.set_accepted_stopsign(self.pid);
                        self.send_accept_stopsign(ss);
                    } else {
                        return Err(ProposeErr::Reconfiguration(new_configuration));
                    }
                }
                (Role::Leader, Phase::FirstAccept) => todo!("Remove entry from first accept"),
                _ => todo!("forward stopsign"),
            }
            Ok(())
        }
    }
/// Propose a reconfiguration. Returns error if already stopped or new configuration is empty.
Propose a reconfiguration. Returns error if already stopped or new configuration is empty.
Propose a reconfiguration . Returns error if already stopped or new configuration is empty .
pub fn reconfigure(&mut self, rc: ReconfigurationRequest) -> Result<(), ProposeErr<T>> {
        let ReconfigurationRequest {
            new_configuration,
            metadata,
        } = rc;
        info!(
            self.logger,
            "Propose reconfiguration {:?}", new_configuration
        );
        if self.stopped() {
            Err(ProposeErr::Reconfiguration(new_configuration))
        } else {
            match self.state {
                (Role::Leader, Phase::Prepare) => {
                    if self.pending_stopsign.is_none() {
                        let ss = StopSign::with(self.config_id + 1, new_configuration, metadata);
                        self.pending_stopsign = Some(ss);
                    } else {
                        return Err(ProposeErr::Reconfiguration(new_configuration));
                    }
                }
                (Role::Leader, Phase::Accept) => {
                    if !self.stopped() {
                        let ss = StopSign::with(self.config_id + 1, new_configuration, metadata);
                        self.storage
                            .set_stopsign(StopSignEntry::with(ss.clone(), false));
                        self.leader_state.set_accepted_stopsign(self.pid);
                        self.send_accept_stopsign(ss);
                    } else {
                        return Err(ProposeErr::Reconfiguration(new_configuration));
                    }
                }
                (Role::Leader, Phase::FirstAccept) => todo!("Remove entry from first accept"),
                _ => todo!("forward stopsign"),
            }
            Ok(())
        }
    }
pub fn reconfigure ( & mut self , rc : ReconfigurationRequest ) -> Result < ( ) , ProposeErr < T > > { let ReconfigurationRequest { new_configuration , metadata , } = rc ; info ! ( self logger " " new_configuration ) ; if self . stopped ( ) { Err ( ProposeErr :: Reconfiguration ( new_configuration ) ) } else { match self . state { ( Role :: Leader , Phase :: Prepare ) => { if self . pending_stopsign . is_none ( ) { let ss = StopSign :: with ( self . config_id + 1 , new_configuration , metadata ) ; self . pending_stopsign = Some ( ss ) ; } else { return Err ( ProposeErr :: Reconfiguration ( new_configuration ) ) ; } } ( Role :: Leader , Phase :: Accept ) => { if ! self . stopped ( ) { let ss = StopSign :: with ( self . config_id + 1 , new_configuration , metadata ) ; self . storage . set_stopsign ( StopSignEntry :: with ( ss . clone ( ) , false ) ) ; self . leader_state . set_accepted_stopsign ( self . pid ) ; self . send_accept_stopsign ( ss ) ; } else { return Err ( ProposeErr :: Reconfiguration ( new_configuration ) ) ; } } ( Role :: Leader , Phase :: FirstAccept ) => todo ! ( " " ) , _ => todo ! ( " " ) , } Ok ( ( ) ) } }
Propose a reconfiguration.
Propose a reconfiguration .
&mut self
rc
ReconfigurationRequest
&mut self
rc
ReconfigurationRequest