From f5e7a15551ddd99196fd674709961bd216806cf9 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 19 Nov 2021 23:09:23 +0000 Subject: [PATCH] Adding support for single-node clusters --- little_raft/src/replica.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/little_raft/src/replica.rs b/little_raft/src/replica.rs index 35bcc87..a3e8974 100644 --- a/little_raft/src/replica.rs +++ b/little_raft/src/replica.rs @@ -703,5 +703,9 @@ where last_log_index: self.log.len() - 1, last_log_term: self.log[self.log.len() - 1].term, }); + + if self.peer_ids.len() == 0 { + self.become_leader(); + } } }