db

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoGet added in v0.9.7

func DoGet(bk Bucket, key []byte) ([]byte, error)

func DoGetWithBucketID added in v0.9.8

func DoGetWithBucketID(dbase Database, bid BucketID, key []byte) ([]byte, error)

func GetFlag added in v0.9.4

func GetFlag(database Database, name string) interface{}

func GetSupportedTypes added in v1.1.1

func GetSupportedTypes() []string

func NewNullDB

func NewNullDB() *nullDB

func NewProxyDB

func NewProxyDB() *proxyDB

func RegisterHasher added in v1.2.9

func RegisterHasher(bk BucketID, hasher Hasher)

func RegisteredBackendTypes added in v0.9.10

func RegisteredBackendTypes() []string

Types

type BackendType

type BackendType string
const GoLevelDBBackend BackendType = "goleveldb"
const MapDBBackend BackendType = "mapdb"

type Bucket

type Bucket interface {
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	Set(key []byte, value []byte) error
	Delete(key []byte) error
}

Bucket

func BucketOf added in v1.3.2

func BucketOf(database Database, id BucketID) Bucket

BucketOf returns valid bucket always, but it

type BucketID

type BucketID string
const (
	// MerkleTrie maps RLP encoded data from sha3(data)
	MerkleTrie BucketID = ""

	// BytesByHash maps data except merkle trie nodes from sha3(data)
	BytesByHash BucketID = "S"

	// TransactionLocatorByHash maps transaction locator from transaction hash.
	TransactionLocatorByHash BucketID = "T"

	// BlockHeaderHashByHeight maps hash of encoded block header from height.
	BlockHeaderHashByHeight BucketID = "H"

	// ChainProperty is general key value map for chain property.
	ChainProperty BucketID = "C"

	// ListByMerkleRootBase is the base for the bucket that maps list
	// from network type dependent merkle root(list)
	ListByMerkleRootBase BucketID = "L"
)

Bucket ID

func (BucketID) Hasher added in v1.2.9

func (bk BucketID) Hasher() Hasher

type CodedBucket added in v0.9.6

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

func NewCodedBucket added in v0.9.6

func NewCodedBucket(database Database, id BucketID, c codec.Codec) (*CodedBucket, error)

func NewCodedBucketFromBucket added in v0.9.7

func NewCodedBucketFromBucket(bk Bucket, hasher Hasher, c codec.Codec) *CodedBucket

func (*CodedBucket) Get added in v0.9.6

func (b *CodedBucket) Get(key interface{}, value interface{}) error

func (*CodedBucket) GetBytes added in v0.9.6

func (b *CodedBucket) GetBytes(key interface{}) ([]byte, error)

func (*CodedBucket) Put added in v0.9.6

func (b *CodedBucket) Put(value interface{}) error

func (*CodedBucket) Set added in v0.9.6

func (b *CodedBucket) Set(key interface{}, value interface{}) error

type Context added in v0.9.4

type Context interface {
	Database
	ContextBuilder
	GetFlag(n string) interface{}
	Flags() Flags
}

func WithFlags added in v0.9.4

func WithFlags(database Database, flags Flags) Context

type ContextBuilder added in v0.9.4

type ContextBuilder interface {
	WithFlags(flags Flags) Context
}

type Database

type Database interface {
	GetBucket(id BucketID) (Bucket, error)
	Close() error
}

func NewMapDB

func NewMapDB() Database

func Open

func Open(dir, dbtype, name string) (Database, error)

func Unwrap added in v1.3.0

func Unwrap(database Database) Database

type Flags added in v0.9.4

type Flags map[string]interface{}

func (Flags) Clone added in v0.9.4

func (f Flags) Clone() Flags

func (Flags) Get added in v0.9.4

func (f Flags) Get(n string) interface{}

func (Flags) Merged added in v0.9.4

func (f Flags) Merged(flags Flags) Flags

type Flusher added in v1.3.10

type Flusher interface {
	Flush() error
}

type GoLevelDB

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

func NewGoLevelDB

func NewGoLevelDB(name string, dir string) (*GoLevelDB, error)

func NewGoLevelDBWithOpts

func NewGoLevelDBWithOpts(name string, dir string, o *opt.Options) (*GoLevelDB, error)

func (*GoLevelDB) Close

func (db *GoLevelDB) Close() error

func (*GoLevelDB) GetBucket

func (db *GoLevelDB) GetBucket(id BucketID) (Bucket, error)

type Hasher added in v1.2.9

type Hasher interface {
	Name() string
	Hash(value []byte) []byte
}

type LayerDB

type LayerDB interface {
	Database
	Flush(write bool) error
	Unwrap() Database
}

func NewLayerDB

func NewLayerDB(database Database) LayerDB

type Raw added in v0.9.6

type Raw []byte

type Writer added in v1.3.10

type Writer interface {
	Database() Database
	Add(item Flusher)
	Prepare()
	Flush() error
}

func NewWriter added in v1.3.10

func NewWriter(dbase Database) Writer

Jump to

Keyboard shortcuts

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