{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v0.6.1-preview","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package db\n\n## Functions\n\n```go\nfunc Start()\n```\nStart the db, init the openchainDB instance and open the db. Note this method has no guarantee correct behavior concurrent invocation.\n\n```go\nfunc Stop()\n```\nStop the db. Note this method has no guarantee correct behavior concurrent invocation.\n\n## Types\n\n```go\ntype OpenchainDB struct {\n\tDB           *gorocksdb.DB\n\tBlockchainCF *gorocksdb.ColumnFamilyHandle\n\tStateCF      *gorocksdb.ColumnFamilyHandle\n\tStateDeltaCF *gorocksdb.ColumnFamilyHandle\n\tIndexesCF    *gorocksdb.ColumnFamilyHandle\n\tPersistCF    *gorocksdb.ColumnFamilyHandle\n}\n```\nOpenchainDB encapsulates rocksdb's structures\n\n```go\nfunc GetDBHandle() *OpenchainDB\n```\nGetDBHandle gets an opened openchainDB singleton. Note that method Start must always be invoked before this method.\n\n```go\nfunc (openchainDB *OpenchainDB) Delete(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) error\n```\nDelete delets the given key in the specified column family\n\n```go\nfunc (openchainDB *OpenchainDB) DeleteState() error\n```\nDeleteState delets ALL state keys/values from the DB. This is generally only used during state synchronization when creating a new state from a snapshot.\n\n```go\nfunc (openchainDB *OpenchainDB) Get(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) ([]byte, error)\n```\nGet returns the valud for the given column family and key\n\n```go\nfunc (openchainDB *OpenchainDB) GetBlockchainCFIterator() *gorocksdb.Iterator\n```\nGetBlockchainCFIterator get iterator for column family - blockchainCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetFromBlockchainCF(key []byte) ([]byte, error)\n```\nGetFromBlockchainCF get value for given key from column family - blockchainCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetFromBlockchainCFSnapshot(snapshot *gorocksdb.Snapshot, key []byte) ([]byte, error)\n```\nGetFromBlockchainCFSnapshot get value for given key from column family in a DB snapshot - blockchainCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetFromIndexesCF(key []byte) ([]byte, error)\n```\nGetFromIndexesCF get value for given key from column family - indexCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetFromStateCF(key []byte) ([]byte, error)\n```\nGetFromStateCF get value for given key from column family - stateCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetFromStateDeltaCF(key []byte) ([]byte, error)\n```\nGetFromStateDeltaCF get value for given key from column family - stateDeltaCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetIterator(cfHandler *gorocksdb.ColumnFamilyHandle) *gorocksdb.Iterator\n```\nGetIterator returns an iterator for the given column family\n\n```go\nfunc (openchainDB *OpenchainDB) GetSnapshot() *gorocksdb.Snapshot\n```\nGetSnapshot returns a point-in-time view of the DB. You MUST call snapshot.Release() when you are done with the snapshot.\n\n```go\nfunc (openchainDB *OpenchainDB) GetStateCFIterator() *gorocksdb.Iterator\n```\nGetStateCFIterator get iterator for column family - stateCF\n\n```go\nfunc (openchainDB *OpenchainDB) GetStateCFSnapshotIterator(snapshot *gorocksdb.Snapshot) *gorocksdb.Iterator\n```\nGetStateCFSnapshotIterator 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.\n\n```go\nfunc (openchainDB *OpenchainDB) GetStateDeltaCFIterator() *gorocksdb.Iterator\n```\nGetStateDeltaCFIterator get iterator for column family - stateDeltaCF\n\n```go\nfunc (openchainDB *OpenchainDB) Put(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte, value []byte) error\n```\nPut saves the key/value in the given column family\n\n```go\ntype TestDBWrapper struct {\n\t// contains filtered or unexported fields\n}\n```\nTestDBWrapper wraps the db. Can be used by other modules for testing\n\n```go\nfunc NewTestDBWrapper() *TestDBWrapper\n```\nNewTestDBWrapper constructs a new TestDBWrapper\n\n```go\nfunc (testDB *TestDBWrapper) CleanDB(t testing.TB)\n```\nCleanDB This method closes existing db, remove the db dir. Can be called before starting a test so that data from other tests does not interfere\n\n```go\nfunc (testDB *TestDBWrapper) CloseDB(t testing.TB)\n```\nCloseDB closes the db\n\n```go\nfunc (testDB *TestDBWrapper) CreateFreshDBGinkgo()\n```\nCreateFreshDBGinkgo creates a fresh database for ginkgo testing\n\n```go\nfunc (testDB *TestDBWrapper) GetDBStats() string\n```\nGetDBStats returns statistics for the database\n\n```go\nfunc (testDB *TestDBWrapper) GetEstimatedNumKeys(t testing.TB) map[string]string\n```\nGetEstimatedNumKeys returns estimated number of key-values in db. This is not accurate in all the cases\n\n```go\nfunc (testDB *TestDBWrapper) GetFromDB(t testing.TB, key []byte) []byte\n```\nGetFromDB gets the value for the given key from default column-family\n\n```go\nfunc (testDB *TestDBWrapper) GetFromStateCF(t testing.TB, key []byte) []byte\n```\nGetFromStateCF tests can use this method for getting value from StateCF column-family\n\n```go\nfunc (testDB *TestDBWrapper) GetFromStateDeltaCF(t testing.TB, key []byte) []byte\n```\nGetFromStateDeltaCF tests can use this method for getting value from StateDeltaCF column-family\n\n```go\nfunc (testDB *TestDBWrapper) OpenDB(t testing.TB)\n```\nOpenDB opens the db\n\n```go\nfunc (testDB *TestDBWrapper) WriteToDB(t testing.TB, writeBatch *gorocksdb.WriteBatch)\n```\nWriteToDB tests can use this method for persisting a given batch to db\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/db","name":"db","synopsis":"","isRedistributable":true}
