database

package
v1.3.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	StoreVersionChainState byte = 1
	CacheSizeDefault            = 1024 * 1024 * 32
)

Variables

Functions

func CheckEngine

func CheckEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine hivedb.Engine) (hivedb.Engine, error)

CheckEngine is a wrapper around hivedb.CheckEngine to throw a custom error message in case of engine mismatch.

func NewRocksDB

func NewRocksDB(path string, cacheSize uint64) (*rocksdb.RocksDB, error)

NewRocksDB creates a new RocksDB instance.

func WithCacheSize added in v1.1.0

func WithCacheSize(cacheSize uint64) options.Option[ChainStateDatabaseManager]

func WithPath

func WithPath(databasePath string) options.Option[ChainStateDatabaseManager]

Types

type ChainStateDatabaseManager

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

func NewChainStateDatabaseManager

func NewChainStateDatabaseManager(chainRecordRegistryProvider registry.ChainRecordRegistryProvider, opts ...options.Option[ChainStateDatabaseManager]) (*ChainStateDatabaseManager, error)

func (*ChainStateDatabaseManager) AreStoresCorrupted

func (m *ChainStateDatabaseManager) AreStoresCorrupted() (bool, error)

func (*ChainStateDatabaseManager) AreStoresTainted

func (m *ChainStateDatabaseManager) AreStoresTainted() (bool, error)

func (*ChainStateDatabaseManager) ChainStateKVStore

func (m *ChainStateDatabaseManager) ChainStateKVStore(chainID isc.ChainID) (kvstore.KVStore, *sync.Mutex, error)

func (*ChainStateDatabaseManager) CheckCorrectStoresVersion

func (m *ChainStateDatabaseManager) CheckCorrectStoresVersion() (bool, error)

func (*ChainStateDatabaseManager) FlushAndCloseStores

func (m *ChainStateDatabaseManager) FlushAndCloseStores() error

func (*ChainStateDatabaseManager) MarkStoresCorrupted

func (m *ChainStateDatabaseManager) MarkStoresCorrupted() error

func (*ChainStateDatabaseManager) MarkStoresHealthy

func (m *ChainStateDatabaseManager) MarkStoresHealthy() error

func (*ChainStateDatabaseManager) MarkStoresTainted

func (m *ChainStateDatabaseManager) MarkStoresTainted() error

func (*ChainStateDatabaseManager) UpdateStoresVersion

func (m *ChainStateDatabaseManager) UpdateStoresVersion() (bool, error)

UpdateStoresVersion tries to migrate the existing data to the new store version.

type ChainStateKVStoreProvider

type ChainStateKVStoreProvider func(chainID isc.ChainID) (kvstore.KVStore, *sync.Mutex, error)

type Database

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

Database holds the underlying KVStore and database specific functions.

func New

func New(databaseDirectory string, kvStore kvstore.KVStore, engine hivedb.Engine, compactionSupported bool, compactionRunningFunc func() bool) *Database

New creates a new Database instance.

func NewDatabase added in v1.1.0

func NewDatabase(
	dbEngine hivedb.Engine,
	path string,
	createDatabaseIfNotExists bool,
	autoFlush bool,
	cacheSize uint64,
) (*Database, error)

NewDatabase opens a database. It also checks if the database engine is correct.

func NewDatabaseInMemory added in v1.1.0

func NewDatabaseInMemory() (*Database, error)

func (*Database) CompactionRunning

func (db *Database) CompactionRunning() bool

CompactionRunning returns whether a compaction is running.

func (*Database) CompactionSupported

func (db *Database) CompactionSupported() bool

CompactionSupported returns whether the database engine supports compaction.

func (*Database) Engine

func (db *Database) Engine() hivedb.Engine

Engine returns the database engine.

func (*Database) KVStore

func (db *Database) KVStore() kvstore.KVStore

KVStore returns the underlying KVStore.

func (*Database) Size

func (db *Database) Size() (int64, error)

Size returns the size of the database.

type StoreVersionUpdateFunc

type StoreVersionUpdateFunc func(store kvstore.KVStore, oldVersion byte, newVersion byte) error

Jump to

Keyboard shortcuts

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