Jing Yang 5 лет назад
Родитель
Сommit
599f453c6e
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      src/lib.rs

+ 3 - 0
src/lib.rs

@@ -436,6 +436,7 @@ impl Raft {
 
         let (tx, rx) = futures::channel::oneshot::channel();
         self.thread_pool.spawn(Self::count_vote_util_cancelled(
+            me,
             term,
             self.inner_state.clone(),
             self.election.clone(),
@@ -464,6 +465,7 @@ impl Raft {
     }
 
     async fn count_vote_util_cancelled(
+        me: Peer,
         term: Term,
         rf: Arc<Mutex<RaftState>>,
         election: Arc<ElectionState>,
@@ -509,6 +511,7 @@ impl Raft {
             election.stop_election_timer();
 
             rf.state = State::Leader;
+            rf.leader_id = me;
             let log_len = rf.log.len();
             for item in rf.next_index.iter_mut() {
                 *item = log_len;