rolling_window_cache

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RollingWindowCache

type RollingWindowCache interface {

	// Has
	// @Description: 判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在
	// @param key
	// @param start
	// @return bool start是否在滑动窗口内
	// @return bool key是否存在
	// @return error
	Has(key string, start uint64) (bool, bool, error)

	// Consumer 消费 chan 中 数据到 RollingWindowCache
	// @Description:
	Consumer()

	// InitGenesis commit genesis block
	// @Description:
	// @param genesisBlock
	// @return error
	InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error

	// CommitBlock  commits the txId and savepoint in an atomic operation
	// @Description:
	// @param blockWithRWSet
	// @param isCache
	// @return error
	CommitBlock(blockWithRWSet *serialization.BlockWithSerializedInfo, isCache bool) error

	// ResetRWCache set RollingWindowCache use blockInfo
	// @Description:
	// @param blockInfo
	// @return error
	ResetRWCache(blockInfo *serialization.BlockWithSerializedInfo) error
}

RollingWindowCache 一个滑动窗口Cache @Description:

func NewRollingWindowCacher

func NewRollingWindowCacher(txIdCount, currCount, startBlockHeight, endBlockHeight, lastBlockHeight uint64,
	logger protocol.Logger) RollingWindowCache

NewRollingWindowCacher 创建一个 滑动窗口 cache @Description: @param txIdCount @param currCount @param startBlockHeight @param endBlockHeight @param lastBlockHeight @param logger @return RollingWindowCache

type RollingWindowCacher

type RollingWindowCacher struct {
	Cache *cache.StoreCacheMgr

	sync.RWMutex
	// contains filtered or unexported fields
}

RollingWindowCacher RollingWindowCacher 中 cache 1.1倍交易池大小 的txid @Description: 保证 当前窗口,可以覆盖 交易池大小的txid 保证 交易在做范围查重时的命中率达到100%

func (*RollingWindowCacher) CommitBlock

func (r *RollingWindowCacher) CommitBlock(blockInfo *serialization.BlockWithSerializedInfo, isCache bool) error

CommitBlock commits the txId to chan @Description: @receiver r @param blockInfo @param isCache @return error

func (*RollingWindowCacher) Consumer

func (r *RollingWindowCacher) Consumer()

Consumer 异步消费 管道数据,完成对滑动窗口缓存的更新 @Description: @receiver r

func (*RollingWindowCacher) Has

func (r *RollingWindowCacher) Has(key string, start uint64) (bool, bool, error)

Has 判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在 @Description: @receiver r @param key @param start @return bool start是否在滑动窗口内 @return bool key是否存在 @return error

func (*RollingWindowCacher) InitGenesis

func (r *RollingWindowCacher) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error

InitGenesis commit genesis block @Description: @receiver r @param genesisBlock @return error

func (*RollingWindowCacher) ResetRWCache

func (r *RollingWindowCacher) ResetRWCache(blockInfo *serialization.BlockWithSerializedInfo) error

ResetRWCache use the last block to reset RWCache ,when blockstore is restarting @Description: @receiver r @param blockInfo @return error

Jump to

Keyboard shortcuts

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