Documentation ¶
Index ¶
- Variables
- func Load(meta Metadata, data interface{}, r io.Reader) error
- func LoadFile(meta Metadata, data interface{}, filename string) error
- func NewSafeFile(filename string) (*safeFile, error)
- func RandomSuffix() string
- func Save(meta Metadata, data interface{}, w io.Writer) error
- func SaveFile(meta Metadata, data interface{}, filename string) error
- type BoltDatabase
- type Metadata
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilEntry = errors.New("entry does not exist") ErrNilBucket = errors.New("bucket does not exist") )
var ( ErrBadVersion = errors.New("incompatible version") ErrBadHeader = errors.New("wrong header") )
var NilDB nildb
NilDB is a db whose methods are no-ops. Calls to Block will return the zero value of types.Block. Calls to Height will return 0.
Functions ¶
func NewSafeFile ¶ added in v1.0.0
func RandomSuffix ¶ added in v1.0.0
func RandomSuffix() string
RandomSuffix returns a 20 character base32 suffix for a filename. There are 100 bits of entropy, and a very low probability of colliding with existing files unintentionally.
Types ¶
type BoltDatabase ¶ added in v1.0.0
func OpenDatabase ¶ added in v1.0.0
func OpenDatabase(meta Metadata, filename string) (*BoltDatabase, error)
openDatabase opens a database filename and checks metadata
func (*BoltDatabase) BucketSize ¶
func (db *BoltDatabase) BucketSize(bucketName []byte) (uint64, error)
BucketSize returns the number of keys in a bucket.
func (*BoltDatabase) CloseDatabase ¶
func (db *BoltDatabase) CloseDatabase() error
CloseDatabase saves the bolt database to a file, and updates metadata
func (*BoltDatabase) Exists ¶
func (db *BoltDatabase) Exists(bucketName []byte, key []byte) (bool, error)
Exists checks for the existance of an item in the specified bucket
func (*BoltDatabase) GetFromBucket ¶
func (db *BoltDatabase) GetFromBucket(bucketName string, key []byte) ([]byte, error)
GetFromBucket is a wrapper around a bolt database lookup. If the element does not exist, no error will be thrown, but the requested element will be nil.