rolling_window_cache

package
v0.0.0-...-8b03266 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: 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 {
	// 判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在
	// return: bool start是否在滑动窗口内, bool key是否存在, error 返回err
	Has(key string, start uint64) (bool, bool, error)
	//消费 chan 中 数据到 RollingWindowCache
	Consumer()
	// InitGenesis commit genesis block
	InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
	// CommitBlock commits the txId and savepoint in an atomic operation
	CommitBlock(blockWithRWSet *serialization.BlockWithSerializedInfo, isCache bool) error
	// ResetRWCache set RollingWindowCache use blockInfo
	ResetRWCache(blockInfo *serialization.BlockWithSerializedInfo) error
}

一个滑动窗口Cache

func NewRollingWindowCacher

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

创建一个 滑动窗口 cache

type RollingWindowCacher

type RollingWindowCacher struct {
	Cache *cache.StoreCacheMgr

	sync.RWMutex
	// contains filtered or unexported fields
}

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

func (*RollingWindowCacher) CommitBlock

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

CommitBlock commits the txId to chan

func (*RollingWindowCacher) Consumer

func (r *RollingWindowCacher) Consumer()

异步消费 管道数据,完成对滑动窗口缓存的更新

func (*RollingWindowCacher) Has

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

判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在 return: bool start是否在滑动窗口内, bool key是否存在, error 返回err

func (*RollingWindowCacher) InitGenesis

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

InitGenesis commit genesis block

func (*RollingWindowCacher) ResetRWCache

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

ResetRWCache: use the last block to reset RWCache ,when blockstore is restarting

Jump to

Keyboard shortcuts

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