Documentation ¶
Overview ¶
Package leveldb is leveldb module
Index ¶
- Constants
- type KvStateDB
- func (db *KvStateDB) Close()
- func (db *KvStateDB) CommitBlockDataAndTxData(chainId string, height uint64, blockData *storage.BlockData, ...) error
- func (db *KvStateDB) GetBlockHeaderAndHeightByHash(chainId string, blockHash []byte) ([]byte, uint64, bool)
- func (db *KvStateDB) GetBlockHeaderByHeight(chainId string, height uint64) ([]byte, bool)
- func (db *KvStateDB) GetChainConfig(chainId string) ([]byte, bool)
- func (db *KvStateDB) GetLastCommittedBlockHeaderAndHeight(chainId string) ([]byte, uint64, bool)
- func (db *KvStateDB) GetTransactionByTxKey(chainId string, txKey string) ([]byte, bool)
- func (db *KvStateDB) GetTransactionHashAndHeightByTxKey(chainId string, txKey string) ([]byte, uint64, bool)
- func (db *KvStateDB) GetTransactionTotalNum(chainId string) (uint64, bool)
- func (db *KvStateDB) GetTxExtraDataByTxKey(chainId string, txKey string) ([]byte, bool)
- func (db *KvStateDB) WriteChainConfig(chainId string, chainConfig []byte) error
- type LevelDBProvider
- func (l *LevelDBProvider) Close()
- func (l *LevelDBProvider) Delete(key string) error
- func (l *LevelDBProvider) Get(key string) ([]byte, bool)
- func (l *LevelDBProvider) Has(key string) (bool, error)
- func (l *LevelDBProvider) Put(key string, value []byte) error
- func (l *LevelDBProvider) WriteBatch(batch *kvdb.Batcher) error
Constants ¶
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 )
keys in level db
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) 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 ¶
GetBlockHeaderByHeight returns the serialized block header given it's height, or returns nil if none exists
func (*KvStateDB) GetChainConfig ¶
GetChainConfig returns chain config, or returns nil if none exists
func (*KvStateDB) GetLastCommittedBlockHeaderAndHeight ¶
GetLastCommittedBlockHeaderAndHeight returns the last committed block header,or returns nil if none exists
func (*KvStateDB) GetTransactionByTxKey ¶
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 ¶
GetTransactionTotalNum returns the total num of transactions, or returns 0 if none exists
func (*KvStateDB) GetTxExtraDataByTxKey ¶
GetTxExtraDataByTxKey returns transaction extra data (rw_set) by txId, or returns nil if none exists
type LevelDBProvider ¶
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) Delete ¶
func (l *LevelDBProvider) Delete(key string) error
Delete delete data by key
func (*LevelDBProvider) Get ¶
func (l *LevelDBProvider) Get(key string) ([]byte, bool)
Get get value by key
func (*LevelDBProvider) Has ¶
func (l *LevelDBProvider) Has(key string) (bool, error)
Has whether has key
func (*LevelDBProvider) Put ¶
func (l *LevelDBProvider) Put(key string, value []byte) error
Put put key and value
func (*LevelDBProvider) WriteBatch ¶
func (l *LevelDBProvider) WriteBatch(batch *kvdb.Batcher) error
WriteBatch write batch