leveldb

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ItemFlagStart       = uint32(0)
	ItemFlagBlock       = uint32(1)
	ItemFlagBlockHeight = uint32(2)
	ItemFlagTrie        = uint32(3)
	ItemFlagAct         = uint32(4)
	ItemFlagTxIndex     = uint32(5)
	ItemFlagCode        = uint32(6)
	ItemFlagKV          = uint32(7)
	ItemFlagAssetCode   = uint32(8)
	ItemFlagAssetId     = uint32(9)
	ItemFlagStop        = uint32(10)
)
View Source
var (
	BlockPrefix = []byte("B")
	BlockSuffix = []byte("b")

	BlockHeightPrefix = []byte("BH")
	BlockHeightSuffix = []byte("bh") // // headerPrefix + height (uint64 big endian) + heightSuffix -> hash

	AccountPrefix = []byte("A")
	AccountSuffix = []byte("a")

	TxPrefix = []byte("TX")
	TxSuffix = []byte("tx")

	AssetCodePrefix = []byte("AC")
	AssetCodeSuffix = []byte("ac")

	AssetIdPrefix = []byte("AI")
	AssetIdSuffix = []byte("ai")

	TrieNodePrefix = []byte("TN")
	TrieNodeSuffix = []byte("tn")

	CodePrefix = []byte("CC")
	CodeSuffix = []byte("cc")

	KVPrefix = []byte("KV")
	KVSuffix = []byte("kv")

	BitCaskCurrentOffsetPrefix = []byte("OFFSET")
	BitCaskCurrentOffsetSuffix = []byte("offset")

	StableBlockKey = []byte("LEMO-CURRENT-BLOCK")
)
View Source
var OpenFileLimit = 64

Functions

func CheckItemFlag

func CheckItemFlag(flg uint32) bool

func DelPos

func DelPos(db DatabaseDeleter, flg uint32, key []byte) error

func EncodeNumber

func EncodeNumber(height uint32) []byte

func Get

func Get(db DatabaseReader, key []byte) ([]byte, error)

func GetCurrentBlock

func GetCurrentBlock(db DatabaseReader) (common.Hash, error)

func GetCurrentPos

func GetCurrentPos(db DatabaseReader, index int) (uint32, error)

func Key

func Key(flag uint32, key []byte) []byte

func Set

func Set(db DatabasePutter, key []byte, val []byte) error

func SetCurrentBlock

func SetCurrentBlock(db DatabasePutter, hash common.Hash) error

func SetCurrentPos

func SetCurrentPos(db DatabasePutter, index int, pos uint32) error

func SetPos

func SetPos(db DatabasePutter, flg uint32, key []byte, position *Position) error

Types

type Batch

type Batch interface {
	DatabasePutter
	ValueSize() int // amount of data in the batch
	Write() error
	// Reset resets the batch for reuse
	Reset()
}

type DatabaseDeleter

type DatabaseDeleter interface {
	Delete(key []byte) error
}

type DatabasePutter

type DatabasePutter interface {
	Put(key []byte, value []byte) error
}

type DatabaseReader

type DatabaseReader interface {
	Get(key []byte) (value []byte, err error)
}

type LevelDBDatabase

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

func NewLevelDBDatabase

func NewLevelDBDatabase(file string, cache int, handles int) *LevelDBDatabase

NewLDBDatabase returns a LevelDB wrapped object.

func (*LevelDBDatabase) Close

func (db *LevelDBDatabase) Close()

func (*LevelDBDatabase) Delete

func (db *LevelDBDatabase) Delete(key []byte) error

Delete deletes the key from the queue and database

func (*LevelDBDatabase) Get

func (db *LevelDBDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*LevelDBDatabase) Has

func (db *LevelDBDatabase) Has(key []byte) (bool, error)

func (*LevelDBDatabase) LDB

func (db *LevelDBDatabase) LDB() *leveldb.DB

func (*LevelDBDatabase) Meter

func (db *LevelDBDatabase) Meter(prefix string)

Meter configures the database metrics collectors and

func (*LevelDBDatabase) NewBatch

func (db *LevelDBDatabase) NewBatch() Batch

func (*LevelDBDatabase) NewIterator

func (db *LevelDBDatabase) NewIterator() iterator.Iterator

func (*LevelDBDatabase) NewIteratorWithPrefix

func (db *LevelDBDatabase) NewIteratorWithPrefix(prefix []byte) iterator.Iterator

NewIteratorWithPrefix returns a iterator to iterate over subset of database content with a particular prefix.

func (*LevelDBDatabase) Path

func (db *LevelDBDatabase) Path() string

Path returns the path to the database directory.

func (*LevelDBDatabase) Put

func (db *LevelDBDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the queue

type Position

type Position struct {
	Flag   uint32
	Offset uint32
}

func GetPos

func GetPos(db DatabaseReader, flg uint32, key []byte) (*Position, error)

Jump to

Keyboard shortcuts

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