database

package
v1.0.3-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoreVersionChainState byte = 1
)

Variables

View Source
var (
	AllowedEnginesDefault = []hivedb.Engine{
		hivedb.EngineAuto,
		hivedb.EngineMapDB,
		hivedb.EngineRocksDB,
	}

	AllowedEnginesStorage = []hivedb.Engine{
		hivedb.EngineRocksDB,
	}

	AllowedEnginesStorageAuto = append(AllowedEnginesStorage, hivedb.EngineAuto)
)

Functions

func CheckEngine

func CheckEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine hivedb.Engine, allowedEngines ...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) (*rocksdb.RocksDB, error)

NewRocksDB creates a new RocksDB instance.

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 DatabaseWithDefaultSettings

func DatabaseWithDefaultSettings(path string, createDatabaseIfNotExists bool, dbEngine hivedb.Engine, autoFlush bool, allowedEngines ...hivedb.Engine) (*Database, error)

DatabaseWithDefaultSettings returns a database with default settings. It also checks if the database engine is correct.

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 (*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