code: public CompletableFuture<Long> appendEntries(long index) {
      if (index == 0)
        return appendEntries();
  
      if (index <= context.getCommitIndex())
        return CompletableFuture.completedFuture(index);
  
      // If there are no other stateful servers in the cluster, immediately commit the index.
      if (context.getClusterState().getActiveMemberStates().isEmpty() && context.getClusterState().getPassiveMemberStates().isEmpty()) {
        long previousCommitIndex = context.getCommitIndex();
        context.setCommitIndex(index);
        context.setGlobalIndex(index);
        completeCommits(previousCommitIndex, index);
        return CompletableFuture.completedFuture(index);
      }
      // If there are no other active members in the cluster, update the commit index and complete the commit.
      // The updated commit index will be sent to passive/reserve members on heartbeats.
      else if (context.getClusterState().getActiveMemberStates().isEmpty()) {
        long previousCommitIndex = context.getCommitIndex();
        context.setCommitIndex(index);
        completeCommits(previousCommitIndex, index);
        return CompletableFuture.completedFuture(index);
      }
  
      // Only send entry-specific AppendRequests to active members of the cluster.
      return appendFutures.computeIfAbsent(index, i -> {
        for (MemberState member : context.getClusterState().getActiveMemberStates()) {
          appendEntries(member);
        }
        return new CompletableFuture<>();
      });
    }
docs: Registers a commit handler for the given commit index.
  
  @param index The index for which to register the handler.
  @return A completable future to be completed once the given log index has been committed.