leveldb

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package leveldb is leveldb module

Index

Constants

View Source
const (
	BlockHeaderPrefix              = "BH/%s"  // BH/chainId+height
	BlockHeightPrefix              = "BH/%s"  // BH/chainId+blockHash
	LastCommittedBlockHeaderPrefix = "LB/%s"  // LB/chainId
	LastCommittedBlockHeightPrefix = "LH/%s"  // LH/chainId
	TxHashPrefix                   = "THA/%s" // THA/chainId+txKey
	TxHeightPrefix                 = "THE/%s" // THE/chainId+txKey
	TxPrefix                       = "TX/%s"  // TX/chainId+txKey
	TxExtraDataPrefix              = "TE/%s"  // TE/chainId+txKey
	TxTotalNumPrefix               = "TT/%s"  // TE/chainId
	ChainConfigPrefix              = "CC/%s"  // CC/chainId
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KvStateDB

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

KvStateDB is the implementation of StateDB interface

func NewKvStateDB

func NewKvStateDB(storeConfig *conf.StoreConfig, log *zap.SugaredLogger) *KvStateDB

NewKvStateDB creates KvStateDB

func (*KvStateDB) Close

func (db *KvStateDB) Close()

Close is used to close database

func (*KvStateDB) CommitBlockDataAndTxData

func (db *KvStateDB) CommitBlockDataAndTxData(chainId string, height uint64,
	blockData *storage.BlockData, txData *storage.TransactionData) error

CommitBlockDataAndTxData commits block data and transaction data in an atomic operation

func (*KvStateDB) GetBlockHeaderAndHeightByHash

func (db *KvStateDB) GetBlockHeaderAndHeightByHash(chainId string, blockHash []byte) ([]byte, uint64, bool)

GetBlockHeaderAndHeightByHash returns the serialized block header and height given it's block hash, or returns nil if none exists

func (*KvStateDB) GetBlockHeaderByHeight

func (db *KvStateDB) GetBlockHeaderByHeight(chainId string, height uint64) ([]byte, bool)

GetBlockHeaderByHeight returns the serialized block header given it's height, or returns nil if none exists

func (*KvStateDB) GetChainConfig

func (db *KvStateDB) GetChainConfig(chainId string) ([]byte, bool)

GetChainConfig returns chain config, or returns nil if none exists

func (*KvStateDB) GetLastCommittedBlockHeaderAndHeight

func (db *KvStateDB) GetLastCommittedBlockHeaderAndHeight(chainId string) ([]byte, uint64, bool)

GetLastCommittedBlockHeaderAndHeight returns the last committed block header,or returns nil if none exists

func (*KvStateDB) GetTransactionByTxKey

func (db *KvStateDB) GetTransactionByTxKey(chainId string, txKey string) ([]byte, bool)

GetTransactionByTxKey returns transaction bytes by txId, or returns nil if none exists

func (*KvStateDB) GetTransactionHashAndHeightByTxKey

func (db *KvStateDB) GetTransactionHashAndHeightByTxKey(chainId string, txKey string) ([]byte, uint64, bool)

GetTransactionHashAndHeightByTxKey returns transaction hash and block height by txId or txHash, or returns nil if none exists

func (*KvStateDB) GetTransactionTotalNum

func (db *KvStateDB) GetTransactionTotalNum(chainId string) (uint64, bool)

GetTransactionTotalNum returns the total num of transactions, or returns 0 if none exists

func (*KvStateDB) GetTxExtraDataByTxKey

func (db *KvStateDB) GetTxExtraDataByTxKey(chainId string, txKey string) ([]byte, bool)

GetTxExtraDataByTxKey returns transaction extra data (rw_set) by txId, or returns nil if none exists

func (*KvStateDB) WriteChainConfig

func (db *KvStateDB) WriteChainConfig(chainId string, chainConfig []byte) error

WriteChainConfig put the chain config to db

type LevelDBProvider

type LevelDBProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LevelDBProvider provides handle to db instances

func NewLevelDBProvider

func NewLevelDBProvider(ldbConfig *conf.LevelDBConfig) *LevelDBProvider

NewLevelDBProvider construct a new Provider for state operation with given config

func (*LevelDBProvider) Close

func (l *LevelDBProvider) Close()

func (*LevelDBProvider) Delete

func (l *LevelDBProvider) Delete(key string) error

func (*LevelDBProvider) Get

func (l *LevelDBProvider) Get(key string) ([]byte, bool)

func (*LevelDBProvider) Has

func (l *LevelDBProvider) Has(key string) (bool, error)

func (*LevelDBProvider) Put

func (l *LevelDBProvider) Put(key string, value []byte) error

func (*LevelDBProvider) WriteBatch

func (l *LevelDBProvider) WriteBatch(batch *kvdb.Batcher) error

Jump to

Keyboard shortcuts

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