begin method

TxnContextV2 begin({
  1. bool readOnly = false,
})

Implementation

TxnContextV2 begin({bool readOnly = false}) {
  final txnId = _nextTxnId++;

  // Snapshot: capture the set of in-flight txnIds right now.
  // Any row created by these txns is invisible to us.
  final activeSnapshot = Set<int>.from(_active.keys);

  final ctx = TxnContextV2(
    txnId:        txnId,
    snapshotTxnId: _lastCommitted,  // highest committed at BEGIN
    activeAtBegin: activeSnapshot,
    readOnly:     readOnly,
  );
  _active[txnId] = ctx;
  return ctx;
}