public TXStateInterface getRealDeal(KeyInfo key, InternalRegion r) {
    if (realDeal == null) {
      if (r == null) { // TODO: stop gap to get tests working
        realDeal = new TXState(this, false, statisticsClock);
      } else {
        // Code to keep going forward
        if (r.hasServerProxy()) {
          realDeal =
              new ClientTXStateStub(r.getCache(), r.getDistributionManager(), this, target, r);
          if (r.getScope().isDistributed()) {
            if (txDistributedClientWarningIssued.compareAndSet(false, true)) {
              logger.warn(
                  "Distributed region {} is being used in a client-initiated transaction.  The transaction will only affect servers and this client.  To keep from seeing this message use 'local' scope in client regions used in transactions.",
                  r.getFullPath());
            }
          }
        } else {
          target = null;
          // wait for the region to be initialized fixes bug 44652
          r.waitOnInitialization(r.getInitializationLatchBeforeGetInitialImage());
          target = r.getOwnerForKey(key);
          if (target == null || target.equals(txMgr.getDM().getId())) {
            realDeal = new TXState(this, false, statisticsClock);
          } else {
            realDeal = new PeerTXStateStub(this, target, onBehalfOfClientMember);
          }
        }
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Built a new TXState: {} me:{}", realDeal, txMgr.getDM().getId());
      }
    }
    if (isRealDealLocal() && !((TXState) realDeal).hasPerformedAnyOperation()) {
      if (r != null && (r instanceof PartitionedRegion || r.isUsedForPartitionedRegionBucket())) {
        firstOperationOnPartitionedRegion = true;
      }
    }
    return realDeal;
  }
This returns either the TXState for the current transaction or a proxy for the state if it is
held in another member. If no state currently exists, one is created

@param key the key of the entry that is currently being modified
@param r the region that is currently being modified
@return the state or a proxy for the state
geode-core/src/main/java/org/apache/geode/internal/cache/TXStateProxyImpl.java