code: ServerContext setLastVotedFor(int candidate) {
      // If we've already voted for another candidate in this term then the last voted for candidate cannot be overridden.
      Assert.stateNot(lastVotedFor != 0 && candidate != 0L, "Already voted for another candidate");
      ServerMember member = cluster.member(candidate);
      Assert.state(member != null, "unknown candidate: %d", candidate);
      this.lastVotedFor = candidate;
      meta.storeVote(this.lastVotedFor);
  
      if (candidate != 0) {
        LOGGER.debug("{} - Voted for {}", cluster.member().address(), member.address());
      } else {
        LOGGER.trace("{} - Reset last voted for", cluster.member().address());
      }
      return this;
    }
docs: Sets the state last voted for candidate.
  
  @param candidate The candidate that was voted for.
  @return The Raft context.