2014-01-08 15:06:17 +00:00
|
|
|
package bolt
|
|
|
|
|
2014-01-10 14:32:12 +00:00
|
|
|
var (
|
2014-01-27 15:11:54 +00:00
|
|
|
InvalidError = &Error{"Invalid database", nil}
|
|
|
|
VersionMismatchError = &Error{"version mismatch", nil}
|
|
|
|
InvalidMetaPageError = &Error{"invalid meta page", nil}
|
2014-01-10 14:32:12 +00:00
|
|
|
)
|
2014-01-08 15:06:17 +00:00
|
|
|
|
2014-01-12 05:51:01 +00:00
|
|
|
const magic uint32 = 0xC0DEC0DE
|
|
|
|
const version uint32 = 1
|
2014-01-10 14:32:12 +00:00
|
|
|
|
|
|
|
type meta struct {
|
2014-01-24 23:32:18 +00:00
|
|
|
magic uint32
|
|
|
|
version uint32
|
2014-01-26 22:29:06 +00:00
|
|
|
sys bucket
|
2014-01-24 23:32:18 +00:00
|
|
|
pageSize uint32
|
|
|
|
pgid pgid
|
|
|
|
txnid txnid
|
2014-01-10 14:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|