db

package
v0.0.7-alphanet Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(db DB, patch Patch) error

func ApplyWithoutOverride

func ApplyWithoutOverride(db db, patch Patch) error

func DebugDB

func DebugDB(db DB) string

func DebugPatch

func DebugPatch(patch Patch) string

func GetEntryByHash

func GetEntryByHash(db DB, hash types.Hash) ([]byte, error)

func GetEntryByHeight

func GetEntryByHeight(db DB, height uint64) ([]byte, error)

func GetFrontierIdentifier

func GetFrontierIdentifier(db DB) types.HashHeight

func GetIdentifierByHash

func GetIdentifierByHash(db DB, hash types.Hash) (*types.HashHeight, error)

func PatchHash

func PatchHash(patch Patch) types.Hash

func SetFrontier

func SetFrontier(db DB, version types.HashHeight, data []byte) error

Types

type Commit

type Commit interface {
	Identifier() types.HashHeight
	Previous() types.HashHeight
	Serialize() ([]byte, error)
}

type DB

type DB interface {
	Get([]byte) ([]byte, error)
	Has([]byte) (bool, error)
	Put(key, value []byte) error
	Delete(key []byte) error

	NewIterator(prefix []byte) StorageIterator
	Subset(prefix []byte) DB

	Apply(Patch) error
	Changes() (Patch, error)
	Snapshot() DB
}

func DisableNotFound

func DisableNotFound(db DB) DB

func NewLevelDB

func NewLevelDB(dirname string) (DB, *leveldb.DB)

func NewLevelDBSnapshotWrapper

func NewLevelDBSnapshotWrapper(ldb *leveldb.Snapshot) DB

func NewLevelDBWrapper

func NewLevelDBWrapper(db *leveldb.DB) DB

func NewMemDB

func NewMemDB() DB

type LevelDBLike

type LevelDBLike interface {
	LevelDBLikeRO
	Put(key []byte, value []byte, wo *opt.WriteOptions) error
}

type LevelDBLikeRO

type LevelDBLikeRO interface {
	Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)
	Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)
	NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
}

type Manager

type Manager interface {
	Frontier() DB
	Get(types.HashHeight) DB
	GetPatch(identifier types.HashHeight) Patch

	Add(Transaction) error
	Pop() error

	Stop() error
	Location() string
}

func NewLevelDBManager

func NewLevelDBManager(dir string) Manager

func NewMemDBManager

func NewMemDBManager(rawDB DB) Manager

type Patch

type Patch interface {
	Put(key []byte, value []byte)
	Delete(key []byte)

	Replay(PatchReplayer) error
	Dump() []byte
}

func DumpDB

func DumpDB(db DB) Patch

func NewPatch

func NewPatch() Patch

func NewPatchFromDump

func NewPatchFromDump(data []byte) (Patch, error)

func PrefixPatchValues

func PrefixPatchValues(patch Patch, prefix []byte) Patch

func RollbackPatch

func RollbackPatch(db DB, patch Patch) Patch

type PatchReplayer

type PatchReplayer interface {
	Put(key []byte, value []byte)
	Delete(key []byte)
}

type StorageIterator

type StorageIterator interface {
	Next() bool

	Key() []byte
	Value() []byte
	Error() error
	Release()
}

type Transaction

type Transaction interface {
	GetCommits() []Commit
	StealChanges() Patch
}

Jump to

Keyboard shortcuts

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