fabric: github.com/hyperledger/fabric/common/ledger/util/leveldbhelper Index | Files

package leveldbhelper

import "github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"

Index

Package Files

leveldb_helper.go leveldb_provider.go

type Conf Uses

type Conf struct {
    DBPath                string
    ExpectedFormatVersion string
}

Conf configuration for `Provider`

`ExpectedFormatVersion` is the expected value of the format key in the internal database. At the time of opening the db, A check is performed that either the db is empty (i.e., opening for the first time) or the value of the formatVersionKey is equal to `ExpectedFormatVersion`. Otherwise, an error is returned. A nil value for ExpectedFormatVersion indicates that the format is never set and hence there is no such record

type DB Uses

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

DB - a wrapper on an actual store

func CreateDB Uses

func CreateDB(conf *Conf) *DB

CreateDB constructs a `DB`

func (*DB) Close Uses

func (dbInst *DB) Close()

Close closes the underlying db

func (*DB) Delete Uses

func (dbInst *DB) Delete(key []byte, sync bool) error

Delete deletes the given key

func (*DB) Get Uses

func (dbInst *DB) Get(key []byte) ([]byte, error)

Get returns the value for the given key

func (*DB) GetIterator Uses

func (dbInst *DB) GetIterator(startKey []byte, endKey []byte) iterator.Iterator

GetIterator returns an iterator over key-value store. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key

func (*DB) IsEmpty Uses

func (dbInst *DB) IsEmpty() (bool, error)

IsEmpty returns whether or not a database is empty

func (*DB) Open Uses

func (dbInst *DB) Open()

Open opens the underlying db

func (*DB) Put Uses

func (dbInst *DB) Put(key []byte, value []byte, sync bool) error

Put saves the key/value

func (*DB) WriteBatch Uses

func (dbInst *DB) WriteBatch(batch *leveldb.Batch, sync bool) error

WriteBatch writes a batch

type DBHandle Uses

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

DBHandle is an handle to a named db

func (*DBHandle) Delete Uses

func (h *DBHandle) Delete(key []byte, sync bool) error

Delete deletes the given key

func (*DBHandle) Get Uses

func (h *DBHandle) Get(key []byte) ([]byte, error)

Get returns the value for the given key

func (*DBHandle) GetIterator Uses

func (h *DBHandle) GetIterator(startKey []byte, endKey []byte) *Iterator

GetIterator gets an handle to iterator. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key

func (*DBHandle) Put Uses

func (h *DBHandle) Put(key []byte, value []byte, sync bool) error

Put saves the key/value

func (*DBHandle) WriteBatch Uses

func (h *DBHandle) WriteBatch(batch *UpdateBatch, sync bool) error

WriteBatch writes a batch in an atomic way

type FileLock Uses

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

FileLock encapsulate the DB that holds the file lock. As the FileLock to be used by a single process/goroutine, there is no need for the semaphore to synchronize the FileLock usage.

func NewFileLock Uses

func NewFileLock(filePath string) *FileLock

NewFileLock returns a new file based lock manager.

func (*FileLock) Lock Uses

func (f *FileLock) Lock() error

Lock acquire a file lock. We achieve this by opening a db for the given filePath. Internally, leveldb acquires a file lock while opening a db. If the db is opened again by the same or another process, error would be returned. When the db is closed or the owner process dies, the lock would be released and hence the other process can open the db. We exploit this leveldb functionality to acquire and release file lock as the leveldb supports this for Windows, Solaris, and Unix.

func (*FileLock) Unlock Uses

func (f *FileLock) Unlock()

Unlock releases a previously acquired lock. We achieve this by closing the previously opened db. FileUnlock can be called multiple times.

type Iterator Uses

type Iterator struct {
    iterator.Iterator
}

Iterator extends actual leveldb iterator

func (*Iterator) Key Uses

func (itr *Iterator) Key() []byte

Key wraps actual leveldb iterator method

type Provider Uses

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

Provider enables to use a single leveldb as multiple logical leveldbs

func NewProvider Uses

func NewProvider(conf *Conf) (*Provider, error)

NewProvider constructs a Provider

func (*Provider) Close Uses

func (p *Provider) Close()

Close closes the underlying leveldb

func (*Provider) GetDBHandle Uses

func (p *Provider) GetDBHandle(dbName string) *DBHandle

GetDBHandle returns a handle to a named db

func (*Provider) GetDataFormat Uses

func (p *Provider) GetDataFormat() (string, error)

GetDataFormat returns the format of the data

type UpdateBatch Uses

type UpdateBatch struct {
    KVs map[string][]byte
}

UpdateBatch encloses the details of multiple `updates`

func NewUpdateBatch Uses

func NewUpdateBatch() *UpdateBatch

NewUpdateBatch constructs an instance of a Batch

func (*UpdateBatch) Delete Uses

func (batch *UpdateBatch) Delete(key []byte)

Delete deletes a Key and associated value

func (*UpdateBatch) Len Uses

func (batch *UpdateBatch) Len() int

Len returns the number of entries in the batch

func (*UpdateBatch) Put Uses

func (batch *UpdateBatch) Put(key []byte, value []byte)

Put adds a KV

Package leveldbhelper imports 12 packages (graph) and is imported by 32 packages. Updated 2019-11-17. Refresh now. Tools for package owners.