code: private CompletableFuture<SimpleEntry<TxnStatus, Integer>> sealActiveTxn(final int epoch,
                                                                               final UUID txId,
                                                                               final boolean commit,
                                                                               final Optional<Version> version) {
          return getActiveTx(epoch, txId).thenCompose(data -> {
              ActiveTxnRecord txnRecord = data.getObject();
              Version dataVersion = version.orElseGet(data::getVersion);
              TxnStatus status = txnRecord.getTxnStatus();
              switch (status) {
                  case OPEN:
                      return sealActiveTx(epoch, txId, commit, txnRecord, dataVersion).thenApply(y ->
                              new SimpleEntry<>(commit ? TxnStatus.COMMITTING : TxnStatus.ABORTING, epoch));
                  case COMMITTING:
                  case COMMITTED:
                      if (commit) {
                          return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
                      } else {
                          throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
                                  "Stream: " + getName() + " Transaction: " + txId.toString() +
                                          " State: " + status.name());
                      }
                  case ABORTING:
                  case ABORTED:
                      if (commit) {
                          throw StoreException.create(StoreException.Type.ILLEGAL_STATE,
                                  "Stream: " + getName() + " Transaction: " + txId.toString() + " State: " +
                                          status.name());
                      } else {
                          return CompletableFuture.completedFuture(new SimpleEntry<>(status, epoch));
                      }
                  default:
                      throw StoreException.create(StoreException.Type.DATA_NOT_FOUND,
                              "Stream: " + getName() + " Transaction: " + txId.toString());
              }
          });
      }
docs: Seal a transaction in OPEN/COMMITTING_TXN/ABORTING state. This method does CAS on the transaction VersionedMetadata node if
  the transaction is in OPEN state, optionally checking version of transaction VersionedMetadata node, if required.
  
  @param epoch   transaction epoch.
  @param txId    transaction identifier.
  @param commit  boolean indicating whether to commit or abort the transaction.
  @param version optional expected version of transaction node to validate before updating it.
  @return        a pair containing transaction status and its epoch.