code: boolean isLogUpToDate(long lastIndex, long lastTerm, Request request) {
      // If the log is empty then vote for the candidate.
      if (context.getLog().isEmpty()) {
        LOGGER.trace("{} - Accepted {}: candidate's log is up-to-date", context.getCluster().member().address(), request);
        return true;
      }
  
      // Read the last entry index and term from the log.
      long localLastIndex = context.getLog().lastIndex();
      long localLastTerm = context.getLog().term(localLastIndex);
  
      // If the candidate's last log term is lower than the local log's last entry term, reject the request.
      if (lastTerm < localLastTerm) {
        LOGGER.trace("{} - Rejected {}: candidate's last log entry ({}) is at a lower term than the local log ({})", context.getCluster().member().address(), request, lastTerm, localLastTerm);
        return false;
      }
  
      // If the candidate's last term is equal to the local log's last entry term, reject the request if the
      // candidate's last index is less than the local log's last index. If the candidate's last log term is
      // greater than the local log's last term then it's considered up to date, and if both have the same term
      // then the candidate's last index must be greater than the local log's last index.
      if (lastTerm == localLastTerm && lastIndex < localLastIndex) {
        LOGGER.trace("{} - Rejected {}: candidate's last log entry ({}) is at a lower index than the local log ({})", context.getCluster().member().address(), request, lastIndex, localLastIndex);
        return false;
      }
  
      // If we made it this far, the candidate's last term is greater than or equal to the local log's last
      // term, and if equal to the local log's last term, the candidate's last index is equal to or greater
      // than the local log's last index.
      LOGGER.trace("{} - Accepted {}: candidate's log is up-to-date", context.getCluster().member().address(), request);
      return true;
    }
docs: Returns a boolean value indicating whether the given candidate's log is up-to-date.