code: public void toLeader() {
          role = RaftRole.LEADER;
          leader(localEndpoint);
          preCandidateState = null;
          candidateState = null;
          leaderState = new LeaderState(lastGroupMembers.remoteMembers(), log.lastLogOrSnapshotIndex());
      }
docs: Switches this node to leader role. Sets local endpoint as current leader.
  Clears (pre)candidate states. Initializes leader state for current members.