leveldb

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBRootDir string
	Logger    *logger.SugarLogger
}

type DBNotFoundErr

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

DBNotFoundErr denotes that the given dbName is not present in the database

func (*DBNotFoundErr) Error

func (e *DBNotFoundErr) Error() string

type LevelDB

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

LevelDB holds information about all created database

func Open

func Open(conf *Config) (*LevelDB, error)

Open opens a leveldb instance to maintain world state

func (*LevelDB) Close

func (l *LevelDB) Close() error

Close closes the database instance by closing all leveldb databases

func (*LevelDB) Commit

func (l *LevelDB) Commit(dbsUpdates map[string]*worldstate.DBUpdates, blockNumber uint64) error

Commit commits the updates to the database

func (*LevelDB) Exist

func (l *LevelDB) Exist(dbName string) bool

Exist returns true if the given database exist. Otherwise, it returns false.

func (*LevelDB) Get

func (l *LevelDB) Get(dbName string, key string) ([]byte, *types.Metadata, error)

Get returns the value of the key present in the database.

func (*LevelDB) GetACL

func (l *LevelDB) GetACL(dbName, key string) (*types.AccessControl, error)

GetACL returns the access control rule for the given key present in the database

func (*LevelDB) GetConfig

func (l *LevelDB) GetConfig() (*types.ClusterConfig, *types.Metadata, error)

GetConfig returns the cluster configuration

func (*LevelDB) GetDBsSnapshot

func (l *LevelDB) GetDBsSnapshot(dbNames []string) (worldstate.DBsSnapshot, error)

func (*LevelDB) GetIndexDefinition

func (l *LevelDB) GetIndexDefinition(dbName string) ([]byte, *types.Metadata, error)

GetIndexDefinition returns the index definition of a given database

func (*LevelDB) GetIterator

func (l *LevelDB) GetIterator(dbName string, startKey, endKey string) (worldstate.Iterator, error)

GetIterator returns an iterator to fetch values associated with a range of keys startKey is inclusive while the endKey is exclusive. An empty startKey (i.e., "") denotes that the caller wants from the first key in the database (lexicographic order). An empty endKey (i.e., "") denotes that the caller wants till the last key in the database (lexicographic order).

func (*LevelDB) GetVersion

func (l *LevelDB) GetVersion(dbName string, key string) (*types.Version, error)

GetVersion returns the version of the key present in the database

func (*LevelDB) Has

func (l *LevelDB) Has(dbName, key string) (bool, error)

Has returns true if the key exist in the database

func (*LevelDB) Height

func (l *LevelDB) Height() (uint64, error)

Height returns the block height of the state database. In other words, it returns the last committed block number

func (*LevelDB) ListDBs

func (l *LevelDB) ListDBs() []string

ListDBs list all user databases

func (*LevelDB) ValidDBName

func (l *LevelDB) ValidDBName(dbName string) bool

ValidDBName returns true if the given dbName is valid

type Snapshots

type Snapshots struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Snapshots) Get

func (s *Snapshots) Get(dbName, key string) ([]byte, *types.Metadata, error)

func (*Snapshots) GetIndexDefinition

func (s *Snapshots) GetIndexDefinition(dbName string) ([]byte, *types.Metadata, error)

func (*Snapshots) GetIterator

func (s *Snapshots) GetIterator(dbName string, startKey, endKey string) (worldstate.Iterator, error)

func (*Snapshots) Release

func (s *Snapshots) Release()

Jump to

Keyboard shortcuts

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