Documentation ¶
Overview ¶
Package database defines interfaces to key value type databases used by various components in go-spacemesh node
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.ErrNotFound
ErrNotFound is special type error for not found in DB.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Put([]byte, []byte) error Delete([]byte) error Get([]byte) ([]byte, error) }
Database wraps all database operations. All methods are safe for concurrent use.
type LDBDatabase ¶
type LDBDatabase struct {
// contains filtered or unexported fields
}
LDBDatabase is a wrapper for leveldb database with concurrent access.
func NewLDBDatabase ¶
NewLDBDatabase returns a LevelDB wrapped object.
func NewMemDatabase ¶
func NewMemDatabase() *LDBDatabase
NewMemDatabase returns a memory database instance.
func (*LDBDatabase) Close ¶
func (db *LDBDatabase) Close()
Close closes database, flushing writes and denying all new write requests.
func (*LDBDatabase) Delete ¶
func (db *LDBDatabase) Delete(key []byte) error
Delete deletes the key from the queue and database.
func (*LDBDatabase) Get ¶
func (db *LDBDatabase) Get(key []byte) ([]byte, error)
Get returns the given key if it's present.
func (*LDBDatabase) Has ¶
func (db *LDBDatabase) Has(key []byte) (bool, error)
Has returns whether the db contains the key.
func (*LDBDatabase) Path ¶
func (db *LDBDatabase) Path() string
Path returns the path to the database directory.