code: public VoteRequest toCandidate() {
          role = RaftRole.CANDIDATE;
          preCandidateState = null;
          leaderState = null;
          candidateState = new CandidateState(majority());
          candidateState.grantVote(localEndpoint);
          persistVote(incrementTerm(), localEndpoint);
  
          return new VoteRequest(localEndpoint, term, log.lastLogOrSnapshotTerm(), log.lastLogOrSnapshotIndex());
      }
docs: Switches this node to candidate role. Clears pre-candidate and leader states.
  Initializes candidate state for current majority and grants vote for local endpoint as a candidate.
  
  @return vote request to sent to other members during leader election