database

package
v0.2.17-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 8 Imported by: 0

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

View Source
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 Getter

type Getter interface {
	Get(key []byte) ([]byte, error)
}

Getter wraps the database read operation.

type LDBDatabase

type LDBDatabase struct {
	// contains filtered or unexported fields
}

LDBDatabase is a wrapper for leveldb database with concurrent access.

func NewLDBDatabase

func NewLDBDatabase(file string, cache int, handles int, logger log.Log) (*LDBDatabase, error)

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.

func (*LDBDatabase) Put

func (db *LDBDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the queue.

Jump to

Keyboard shortcuts

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