tikvdbprovider

package module
v0.0.0-...-8fa41b1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

README

store-tikv

介绍

hercules 链 tikv 账本存储模块

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
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"
	//PrefixSeparator prefix and raw key separator
	PrefixSeparator = "#"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator will walk through the key between startKey and endKey and return paired value. since protocol.ParametersValueMaxLength == 1024 * 1024 byte == 1MB, so we can just fetch a batch of values in memory without worrying about too much memory occupied, default batchSize is 10 (can modify in need), and we will keep this batch of in use kvs in memory, and fresh it if iter entered next or previous batch

func NewIterator

func NewIterator(db *rawkv.Client, start []byte, end []byte, limit int,
	batchSize int, keyPrefix []byte) (*Iterator, error)

func (*Iterator) Error

func (iter *Iterator) Error() error

func (*Iterator) First

func (iter *Iterator) First() bool

func (*Iterator) Key

func (iter *Iterator) Key() []byte

func (*Iterator) Next

func (iter *Iterator) Next() bool

func (*Iterator) Release

func (iter *Iterator) Release()

func (*Iterator) Value

func (iter *Iterator) Value() []byte

type NewTikvDBOptions

type NewTikvDBOptions struct {
	Config    *TiKVDbConfig
	Logger    protocol.Logger
	Encryptor crypto.SymmetricKey
	ChainId   string
	DbName    string
}

type TiKVDBHandle

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

TiKVDBHandle encapsulated handle to tikvdb

func NewTiKVDBHandle

func NewTiKVDBHandle(input *NewTikvDBOptions) *TiKVDBHandle

func (*TiKVDBHandle) Close

func (h *TiKVDBHandle) Close() error

Close closes the tikvdb

func (*TiKVDBHandle) CompactRange

func (h *TiKVDBHandle) CompactRange(_, _ []byte) error

CompactRange compacts the underlying DB for the given key range.

func (*TiKVDBHandle) Delete

func (h *TiKVDBHandle) Delete(key []byte) error

Delete deletes the given key

func (*TiKVDBHandle) Get

func (h *TiKVDBHandle) Get(key []byte) ([]byte, error)

Get returns the value for the given key, or returns nil if none exists

func (*TiKVDBHandle) GetDbType

func (h *TiKVDBHandle) GetDbType() string

GetDbType returns db type

func (*TiKVDBHandle) GetWriteBatchSize

func (h *TiKVDBHandle) GetWriteBatchSize() uint64

func (*TiKVDBHandle) Has

func (h *TiKVDBHandle) Has(key []byte) (bool, error)

Has return true if the given key exist, or return false if none exists

func (*TiKVDBHandle) NewIteratorWithPrefix

func (h *TiKVDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)

NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix

func (*TiKVDBHandle) NewIteratorWithRange

func (h *TiKVDBHandle) 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.

func (*TiKVDBHandle) Put

func (h *TiKVDBHandle) Put(key []byte, value []byte) error

Put saves the key-values

func (*TiKVDBHandle) WriteBatch

func (h *TiKVDBHandle) WriteBatch(batch protocol.StoreBatcher, _ bool) error

WriteBatch writes a batch in an atomic operation

type TiKVDbConfig

type TiKVDbConfig struct {
	Endpoints            string `mapstructure:"endpoints"`
	MaxBatchCount        uint   `mapstructure:"max_batch_count"`
	GrpcConnectionCount  uint   `mapstructure:"grpc_connection_count"`
	GrpcKeepAliveTime    uint   `mapstructure:"grpc_keep_alive_time"`
	GrpcKeepAliveTimeout uint   `mapstructure:"grpc_keep_alive_timeout"`
	WriteBatchSize       uint64 `mapstructure:"write_batch_size"`
	MaxScanLimit         uint64 `mapstructure:"max_scan_limit"`
	ScanBatchSize        uint64 `mapstructure:"scan_batch_size"`
	DbPrefix             string `mapstructure:"db_prefix"`
}

Jump to

Keyboard shortcuts

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