db

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2016 License: Apache-2.0 Imports: 9 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDB

func CreateDB() error

CreateDB creates a rocks db database

Types

type OpenchainDB

type OpenchainDB struct {
	DB           *gorocksdb.DB
	BlockchainCF *gorocksdb.ColumnFamilyHandle
	StateCF      *gorocksdb.ColumnFamilyHandle
	StateDeltaCF *gorocksdb.ColumnFamilyHandle
	IndexesCF    *gorocksdb.ColumnFamilyHandle
}

OpenchainDB encapsulates rocksdb's structures

func GetDBHandle

func GetDBHandle() *OpenchainDB

GetDBHandle returns a handle to OpenchainDB

func (*OpenchainDB) CloseDB

func (openchainDB *OpenchainDB) CloseDB()

CloseDB releases all column family handles and closes rocksdb

func (*OpenchainDB) DeleteState

func (openchainDB *OpenchainDB) DeleteState() error

DeleteState delets ALL state keys/values from the DB. This is generally only used during state synchronization when creating a new state from a snapshot.

func (*OpenchainDB) GetBlockchainCFIterator

func (openchainDB *OpenchainDB) GetBlockchainCFIterator() *gorocksdb.Iterator

GetBlockchainCFIterator get iterator for column family - blockchainCF

func (*OpenchainDB) GetFromBlockchainCF

func (openchainDB *OpenchainDB) GetFromBlockchainCF(key []byte) ([]byte, error)

GetFromBlockchainCF get value for given key from column family - blockchainCF

func (*OpenchainDB) GetFromBlockchainCFSnapshot

func (openchainDB *OpenchainDB) GetFromBlockchainCFSnapshot(snapshot *gorocksdb.Snapshot, key []byte) ([]byte, error)

GetFromBlockchainCFSnapshot get value for given key from column family in a DB snapshot - blockchainCF

func (*OpenchainDB) GetFromIndexesCF

func (openchainDB *OpenchainDB) GetFromIndexesCF(key []byte) ([]byte, error)

GetFromIndexesCF get value for given key from column family - indexCF

func (*OpenchainDB) GetFromStateCF

func (openchainDB *OpenchainDB) GetFromStateCF(key []byte) ([]byte, error)

GetFromStateCF get value for given key from column family - stateCF

func (*OpenchainDB) GetFromStateDeltaCF

func (openchainDB *OpenchainDB) GetFromStateDeltaCF(key []byte) ([]byte, error)

GetFromStateDeltaCF get value for given key from column family - stateDeltaCF

func (*OpenchainDB) GetSnapshot

func (openchainDB *OpenchainDB) GetSnapshot() *gorocksdb.Snapshot

GetSnapshot returns a point-in-time view of the DB. You MUST call snapshot.Release() when you are done with the snapshot.

func (*OpenchainDB) GetStateCFIterator

func (openchainDB *OpenchainDB) GetStateCFIterator() *gorocksdb.Iterator

GetStateCFIterator get iterator for column family - stateCF

func (*OpenchainDB) GetStateCFSnapshotIterator

func (openchainDB *OpenchainDB) GetStateCFSnapshotIterator(snapshot *gorocksdb.Snapshot) *gorocksdb.Iterator

GetStateCFSnapshotIterator get iterator for column family - stateCF. This iterator is based on a snapshot and should be used for long running scans, such as reading the entire state. Remember to call iterator.Close() when you are done.

func (*OpenchainDB) GetStateDeltaCFIterator

func (openchainDB *OpenchainDB) GetStateDeltaCFIterator() *gorocksdb.Iterator

GetStateDeltaCFIterator get iterator for column family - stateDeltaCF

type TestDBWrapper

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

TestDBWrapper wraps the db. Can be used by other modules for testing

func NewTestDBWrapper

func NewTestDBWrapper() *TestDBWrapper

NewTestDBWrapper constructs a new TestDBWrapper

func (*TestDBWrapper) CreateFreshDB

func (testDB *TestDBWrapper) CreateFreshDB(t *testing.T)

CreateFreshDB This method closes existing db, remove the db dir and create db again. Can be called before starting a test so that data from other tests does not interfere

func (*TestDBWrapper) GetFromStateCF

func (testDB *TestDBWrapper) GetFromStateCF(t *testing.T, key []byte) []byte

GetFromStateCF tests can use this method for getting value from StateCF column-family

func (*TestDBWrapper) GetFromStateDeltaCF

func (testDB *TestDBWrapper) GetFromStateDeltaCF(t *testing.T, key []byte) []byte

GetFromStateDeltaCF tests can use this method for getting value from StateDeltaCF column-family

func (*TestDBWrapper) WriteToDB

func (testDB *TestDBWrapper) WriteToDB(t *testing.T, writeBatch *gorocksdb.WriteBatch)

WriteToDB tests can use this method for persisting a given batch to db

Jump to

Keyboard shortcuts

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