func newTx()

in tx.go [91:121]


func newTx(file *File, id uint64, lock sync.Locker, settings TxOptions) *Tx {
	meta := file.getMetaPage()
	invariant.Check(meta != nil, "file meta is not set")

	rootID := meta.root.Get()
	dataEndMarker := meta.dataEndMarker.Get()

	tx := &Tx{
		flags: txFlags{
			readonly: settings.Readonly,
			active:   true,
		},
		file:      file,
		lock:      lock,
		rootID:    rootID,
		dataEndID: dataEndMarker,

		pages: map[PageID]*Page{},
	}

	if !settings.Readonly {
		tx.writeSync = newTxWriteSync()
		tx.alloc = file.allocator.makeTxAllocState(
			settings.EnableOverflowArea,
			settings.MetaAreaGrowPercentage,
		)
		tx.wal = file.wal.makeTxWALState(settings.WALLimit)
	}

	return tx
}