The example below shows the raft output. Since there was no beginning leader, ActorServer1 was the first to timeout. It sent a heartbeat to all actorServers who then replied with a positive or negative answer if they are their leader. Since we are only running 5 servers, we need a consensus of 3. Therefore actorServer 1 became the leader. It begins sending heartbeats as the leader and then is told to crash. When it crashed, actorServer4 has the first timeout, increased its phase and became a leaderElect. Once a consensus was made by the other actorServers, it then became the new leader and sends heartbeats.
From the below example, upon start, prior to a leader, actorServer2 was down. ActorServer4 was the first to timeout, so held an election. Majority was voted so actorServer4 became the leader and sends heartbeats. ActorServer5 crashes. ActorServer1 crashes. ActorServer2 comes back up and adjusts to phase1 on its first heartbeat from leader. The leader, actorServer4, then crashes at the same time actorServer1 comes back online. ActorServer3 times out so holds an election (leaderElect) by sending heartbeats with a next phase. It gets voted in and becomes the leader so continues sending heartbeats to all actorServers.