fn start_follower_loop(&self) {
        info!("{}: starting follower loop", self.me);
        loop {
            let current_time = time::Instant::now();
            let rng = rand::thread_rng().gen_range(50, 100);
            let sleep_dur = FOLLOWER_TIMEOUT + rng;
            thread::sleep(time::Duration::from_millis(sleep_dur));
            let mut state = self.state.lock().unwrap();
            match state.role {
                Role::Candidate | Role::Leader => break,
                _ => (),
            }
            info!("{}: still follower - checking heartbeat timeout", self.me);
            match state.last_heartbeat_time {
                Some(t) if t > current_time => {
                    info!("{}: staying as follower", self.me);
                    continue; // received message after the previous sleep
                }
                _ => {
                    // revert to candidate state
                    info!("{}: election timeout - transitioning to candidate", self.me);
                    state.role = Role::Candidate;
                    break;
                }
            }
        }
    }
// loop while in follower state
// check if there has been a message
loop while in follower state
check if there has been a message
loop while in follower state check if there has been a message
fn start_follower_loop(&self) {
        info!("{}: starting follower loop", self.me);
        loop {
            let current_time = time::Instant::now();
            let rng = rand::thread_rng().gen_range(50, 100);
            let sleep_dur = FOLLOWER_TIMEOUT + rng;
            thread::sleep(time::Duration::from_millis(sleep_dur));
            let mut state = self.state.lock().unwrap();
            match state.role {
                Role::Candidate | Role::Leader => break,
                _ => (),
            }
            info!("{}: still follower - checking heartbeat timeout", self.me);
            match state.last_heartbeat_time {
                Some(t) if t > current_time => {
                    info!("{}: staying as follower", self.me);
                    continue; // received message after the previous sleep
                }
                _ => {
                    // revert to candidate state
                    info!("{}: election timeout - transitioning to candidate", self.me);
                    state.role = Role::Candidate;
                    break;
                }
            }
        }
    }
fn start_follower_loop ( & self ) { info ! ( " " self me ) ; loop { let current_time = time :: Instant :: now ( ) ; let rng = rand :: thread_rng ( ) . gen_range ( 50 , 100 ) ; let sleep_dur = FOLLOWER_TIMEOUT + rng ; thread :: sleep ( time :: Duration :: from_millis ( sleep_dur ) ) ; let mut state = self . state . lock ( ) . unwrap ( ) ; match state . role { Role :: Candidate | Role :: Leader => break , _ => ( ) , } info ! ( " " self me ) ; match state . last_heartbeat_time { Some ( t ) if t > current_time => { info ! ( " " self me ) ; continue ; // received message after the previous sleep } _ => { // revert to candidate state info ! ( " " self me ) ; state . role = Role :: Candidate ; break ; } } } }
loop while in follower state
check if there has been a message
loop while in follower state check if there has been a message
&self