MCPcopy
hub / github.com/etcd-io/bbolt / init

Method init

tx.go:47–65  ·  view source on GitHub ↗

init initializes the transaction.

(db *DB)

Source from the content-addressed store, hash-verified

45
46// init initializes the transaction.
47func (tx *Tx) init(db *DB) {
48 tx.db = db
49 tx.pages = nil
50
51 // Copy the meta page since it can be changed by the writer.
52 tx.meta = &common.Meta{}
53 db.meta().Copy(tx.meta)
54
55 // Copy over the root bucket.
56 tx.root = newBucket(tx)
57 tx.root.InBucket = &common.InBucket{}
58 *tx.root.InBucket = *(tx.meta.RootBucket())
59
60 // Increment the transaction id and add a page cache for writable transactions.
61 if tx.writable {
62 tx.pages = make(map[common.Pgid]*common.Page)
63 tx.meta.IncTxid()
64 }
65}
66
67// ID returns the transaction id.
68func (tx *Tx) ID() int {

Callers 2

beginTxMethod · 0.95
beginRWTxMethod · 0.95

Calls 5

newBucketFunction · 0.85
metaMethod · 0.80
RootBucketMethod · 0.80
IncTxidMethod · 0.80
CopyMethod · 0.45

Tested by

no test coverage detected