docs: public final void ensureOrder(TotalOrderRemoteTransactionState state, Collection<?> keysModified) throws InterruptedException {
        //the retries due to state transfer re-uses the same state. we need that the keys previous locked to be release
        //in order to insert it again in the keys locked.
        //NOTE: this method does not need to be synchronized because it is invoked by a one thread at the time, namely
        //the thread that is delivering the messages in total order.
        state.awaitUntilReset();
        TotalOrderLatch transactionSynchronizedBlock = new TotalOrderLatchImpl(state.getGlobalTransaction().globalId());
        state.setTransactionSynchronizedBlock(transactionSynchronizedBlock);
           //this will collect all the count down latch corresponding to the previous transactions in the queue
           for (Object key : keysModified) {
              TotalOrderLatch prevTx = keysLocked.put(key, transactionSynchronizedBlock);
              if (prevTx != null) {
                 state.addSynchronizedBlock(prevTx);
              }
              state.addLockedKey(key);
  
        }
  
        TotalOrderLatch stateTransfer = stateTransferInProgress.get();
        if (stateTransfer != null) {
           state.addSynchronizedBlock(stateTransfer);
        }
  
        if (trace) {
           log.tracef("Transaction [%s] will wait for %s and locked %s", state.getGlobalTransaction().globalId(),
                      state.getConflictingTransactionBlocks(), state.getLockedKeys() == null ? "[ClearCommand]" :
                 state.getLockedKeys());
        }
     }