aboutsummaryrefslogtreecommitdiff
path: root/meta.go
blob: 3da5bc309b977870f3aa2f05541ef414f0d10585 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package bolt

var (
	InvalidError         = &Error{"Invalid database", nil}
	VersionMismatchError = &Error{"version mismatch", nil}
)

const magic uint32 = 0xC0DEC0DE
const version uint32 = 1

type meta struct {
	magic    uint32
	version  uint32
	pageSize uint32
	pgid     pgid
	txnid    txnid
	free     pgid
	sys      bucket
}

// validate checks the marker bytes and version of the meta page to ensure it matches this binary.
func (m *meta) validate() error {
	if m.magic != magic {
		return InvalidError
	} else if m.version != Version {
		return VersionMismatchError
	}
	return nil
}

// copy copies one meta object to another.
func (m *meta) copy(dest *meta) {
	dest.pageSize = m.pageSize
	dest.pgid = m.pgid
	dest.txnid = m.txnid
	dest.sys = m.sys
}