Documentation ¶
Index ¶
- Constants
- Variables
- type EncryptedIterator
- type LevelDBHandle
- func (h *LevelDBHandle) Close() error
- func (h *LevelDBHandle) CompactRange(start, limit []byte) error
- func (h *LevelDBHandle) Delete(key []byte) error
- func (h *LevelDBHandle) Get(key []byte) ([]byte, error)
- func (h *LevelDBHandle) GetDbType() string
- func (h *LevelDBHandle) GetKeys(keys [][]byte) ([][]byte, error)
- func (h *LevelDBHandle) GetWriteBatchSize() uint64
- func (h *LevelDBHandle) Has(key []byte) (bool, error)
- func (h *LevelDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
- func (h *LevelDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)
- func (h *LevelDBHandle) Put(key []byte, value []byte) error
- func (h *LevelDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
- type LevelDbConfig
- type MemdbHandle
- func (db *MemdbHandle) Close() error
- func (db *MemdbHandle) CompactRange(start []byte, limit []byte) error
- func (db *MemdbHandle) Delete(key []byte) error
- func (db *MemdbHandle) Get(key []byte) ([]byte, error)
- func (db *MemdbHandle) GetDbType() string
- func (db *MemdbHandle) GetKeys(keys [][]byte) ([][]byte, error)
- func (db *MemdbHandle) GetWriteBatchSize() uint64
- func (db *MemdbHandle) Has(key []byte) (bool, error)
- func (db *MemdbHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
- func (db *MemdbHandle) NewIteratorWithRange(start []byte, limit []byte) (protocol.Iterator, error)
- func (db *MemdbHandle) Put(key []byte, value []byte) error
- func (db *MemdbHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
- type NewLevelDBOptions
Constants ¶
const ( //StoreBlockDBDir blockdb folder name StoreBlockDBDir = "store_block" //StoreStateDBDir statedb folder name StoreStateDBDir = "store_state" //StoreHistoryDBDir historydb folder name StoreHistoryDBDir = "store_history" //StoreResultDBDir resultdb folder name StoreResultDBDir = "store_result" )
Variables ¶
var DbType_Leveldb = "leveldb"
DbType_Leveldb string "leveldb"
ErrBatch for check batch type
Functions ¶
This section is empty.
Types ¶
type EncryptedIterator ¶
type EncryptedIterator struct {
// contains filtered or unexported fields
}
EncryptedIterator 具有数据解密的迭代器
func NewEncryptedIterator ¶
func NewEncryptedIterator(it iterator.Iterator, encryptor crypto.SymmetricKey) *EncryptedIterator
NewEncryptedIterator construct an Encrypted Iterator @param iterator.Iterator @param crypto.SymmetricKey @return *EncryptedIterator
func (*EncryptedIterator) Error ¶
func (e *EncryptedIterator) Error() error
Error return any error generated by EncryptedIterator @return error
func (*EncryptedIterator) First ¶
func (e *EncryptedIterator) First() bool
First reset the iterator @return bool
func (*EncryptedIterator) Key ¶
func (e *EncryptedIterator) Key() []byte
Key reutrn current key @return []byte key
func (*EncryptedIterator) Next ¶
func (e *EncryptedIterator) Next() bool
Next check iterator whether has next element @return bool
func (*EncryptedIterator) Release ¶
func (e *EncryptedIterator) Release()
Release close the db ,release the iterator
func (*EncryptedIterator) Value ¶
func (e *EncryptedIterator) Value() []byte
Value return current value, and decrypt the value @return []byte value located at currentIndex
type LevelDBHandle ¶
type LevelDBHandle struct {
// contains filtered or unexported fields
}
LevelDBHandle encapsulated handle to leveldb
func NewLevelDBHandle ¶
func NewLevelDBHandle(options *NewLevelDBOptions) *LevelDBHandle
NewLevelDBHandle use NewLevelDBOptions to build LevelDBHandle @param NewLevelDBOptions config @return *LevelDBHandle dbhandler
func (*LevelDBHandle) Close ¶
func (h *LevelDBHandle) Close() error
Close closes the leveldb @return error
func (*LevelDBHandle) CompactRange ¶
func (h *LevelDBHandle) CompactRange(start, limit []byte) error
CompactRange compacts the underlying DB for the given key range. @param []byte start @param []byte limit @return error
func (*LevelDBHandle) Delete ¶
func (h *LevelDBHandle) Delete(key []byte) error
Delete deletes the given key @param []byte key @return error
func (*LevelDBHandle) Get ¶
func (h *LevelDBHandle) Get(key []byte) ([]byte, error)
Get returns the value for the given key, or returns nil if none exists @param []byte key @return []byte @return error
func (*LevelDBHandle) GetDbType ¶ added in v2.2.0
func (h *LevelDBHandle) GetDbType() string
GetDbType returns db type , "leveldb"(default) @return string
func (*LevelDBHandle) GetKeys ¶ added in v2.3.0
func (h *LevelDBHandle) GetKeys(keys [][]byte) ([][]byte, error)
GetKeys returns the value for the given key @param [][]byte multi keys @return [][]byte multi values @return error
func (*LevelDBHandle) GetWriteBatchSize ¶
func (h *LevelDBHandle) GetWriteBatchSize() uint64
GetWriteBatchSize return writeBatchSize @return uint64
func (*LevelDBHandle) Has ¶
func (h *LevelDBHandle) Has(key []byte) (bool, error)
Has return true if the given key exist, or return false if none exists @param []byte key @return bool @return error
func (*LevelDBHandle) NewIteratorWithPrefix ¶
func (h *LevelDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix @param []byte prefix @return protocol.Iterator @return error
func (*LevelDBHandle) NewIteratorWithRange ¶
func (h *LevelDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)
NewIteratorWithRange returns an iterator that contains all the key-values between given key ranges start is included in the results and limit is excluded. @param []byte startKey @param []byte limitKey @return protocol.Iterator @return error
func (*LevelDBHandle) Put ¶
func (h *LevelDBHandle) Put(key []byte, value []byte) error
Put saves the key-values @param []byte key @param []byte value @return error
func (*LevelDBHandle) WriteBatch ¶
func (h *LevelDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
WriteBatch writes a batch in an atomic operation @param protocol.StoreBatcher @param bool sync @return error
type LevelDbConfig ¶
type LevelDbConfig struct { StorePath string `mapstructure:"store_path"` WriteBatchSize uint64 `mapstructure:"write_batch_size"` WriteBufferSize int `mapstructure:"write_buffer_size"` BloomFilterBits int `mapstructure:"bloom_filter_bits"` NoSync bool `mapstructure:"no_sync"` DisableBufferPool bool `mapstructure:"disable_buffer_pool"` Compression uint `mapstructure:"compression"` DisableBlockCache bool `mapstructure:"disable_block_cache"` BlockCacheCapacity int `mapstructure:"block_cache_capacity"` BlockSize int `mapstructure:"block_size"` CompactionTableSize int `mapstructure:"compaction_table_size"` CompactionTotalSize int `mapstructure:"compaction_total_size"` WriteL0PauseTrigger int `mapstructure:"write_l0_pause_trigger"` WriteL0SlowdownTrigger int `mapstructure:"write_l0_slowdown_trigger"` CompactionL0Trigger int `mapstructure:"compaction_l0_trigger"` }
LevelDbConfig config the levelDB store
type MemdbHandle ¶
type MemdbHandle struct {
// contains filtered or unexported fields
}
MemdbHandle in-memory key/value database handler
func NewMemdbHandle ¶
func NewMemdbHandle() *MemdbHandle
NewMemdbHandle construct default MemdbHandle @return *MemdbHandle
func (*MemdbHandle) Close ¶
func (db *MemdbHandle) Close() error
Close reset db to initial empty state @return error
func (*MemdbHandle) CompactRange ¶
func (db *MemdbHandle) CompactRange(start []byte, limit []byte) error
CompactRange return nil (default) @param []byte start @param []byte limit @return error
func (*MemdbHandle) Delete ¶
func (db *MemdbHandle) Delete(key []byte) error
Delete deletes the given key @param []byte key @return error
func (*MemdbHandle) Get ¶
func (db *MemdbHandle) Get(key []byte) ([]byte, error)
Get get value @param []byte key @return []byte value @return error
func (*MemdbHandle) GetDbType ¶ added in v2.2.0
func (db *MemdbHandle) GetDbType() string
GetDbType return "leveldb" @return string
func (*MemdbHandle) GetKeys ¶ added in v2.3.0
func (db *MemdbHandle) GetKeys(keys [][]byte) ([][]byte, error)
GetKeys use multi goroutine to get keys @param [][]byte multi keys @return [][]byte multi values @return error
func (*MemdbHandle) GetWriteBatchSize ¶
func (db *MemdbHandle) GetWriteBatchSize() uint64
GetWriteBatchSize return writeBatchSize , 0 (default) @return uint64
func (*MemdbHandle) Has ¶
func (db *MemdbHandle) Has(key []byte) (bool, error)
Has return true if the given key exist, or return false if none exists @param []byte key @return bool @return error
func (*MemdbHandle) NewIteratorWithPrefix ¶
func (db *MemdbHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix @param []byte prefix @return protocol.Iterator @return error
func (*MemdbHandle) NewIteratorWithRange ¶
func (db *MemdbHandle) NewIteratorWithRange(start []byte, limit []byte) (protocol.Iterator, error)
NewIteratorWithRange returns an iterator that contains all the key-values between given key ranges start is included in the results and limit is excluded. @param []byte start @param []byte limit @return protocol.Iterator @return error
func (*MemdbHandle) Put ¶
func (db *MemdbHandle) Put(key []byte, value []byte) error
Put saves the key-values @param []byte key @param []byte value @return error
func (*MemdbHandle) WriteBatch ¶
func (db *MemdbHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
WriteBatch writes a batch in an atomic operation @param protocol.StoreBatcher @param bool sync @return error
type NewLevelDBOptions ¶
type NewLevelDBOptions struct { Config *LevelDbConfig Logger protocol.Logger Encryptor crypto.SymmetricKey ChainId string DbFolder string }
NewLevelDBOptions used to build LevelDBHandle