persist

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadVersion = errors.New("incompatible version")
	ErrBadHeader  = errors.New("wrong header")
)
View Source
var (
	ErrUnknownBlock = errors.New("unknown block")
)
View Source
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 Load added in v0.3.3

func Load(meta Metadata, data interface{}, r io.Reader) error

Load loads data from a reader.

func LoadFile added in v0.3.3

func LoadFile(meta Metadata, data interface{}, filename string) error

LoadFile loads data from a file.

func Save added in v0.3.3

func Save(meta Metadata, data interface{}, w io.Writer) error

Save saves data to a writer.

func SaveFile added in v0.3.3

func SaveFile(meta Metadata, data interface{}, filename string) error

SaveFile saves data to a file.

Types

type DB

type DB interface {
	Block(types.BlockHeight) (types.Block, error)
	AddBlock(types.Block) error
	RemoveBlock() error
	Height() (types.BlockHeight, error)
	Close() error
}

A DB is a block database. Right now it is equivalent to a []Block.

func OpenDB

func OpenDB(filename string) (DB, error)

OpenDB returns a database ready for use. If the database file does not exist, it will be created. Only one view of a given database file should be open at any one time.

type Metadata added in v0.3.3

type Metadata struct {
	Header, Version string
}

Metadata contains the header and version of the data being stored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL