rolling_window_cache

package
v2.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClockTurntable added in v2.3.3

type ClockTurntable interface {
	// Get returns the value by given the time
	Get(t time.Time) uint64
	// GetLastSecond returns the sum of value of last n seconds
	GetLastSecond(n uint64) uint64
	// Add given n, that the value corresponding to the current moment, plus one n
	Add(n uint64)
}

ClockTurntable a clock turntable

type ClockTurntableInstrument added in v2.3.3

type ClockTurntableInstrument struct {
	Status [60]*subStatus
}

ClockTurntableInstrument clock turntable implementation

func NewClockTurntableInstrument added in v2.3.3

func NewClockTurntableInstrument() *ClockTurntableInstrument

NewClockTurntableInstrument create a new instance

func (*ClockTurntableInstrument) Add added in v2.3.3

func (C *ClockTurntableInstrument) Add(n uint64)

Add given n, that the value corresponding to the current moment, plus one n

func (*ClockTurntableInstrument) Get added in v2.3.3

Get returns the value by given the time

func (*ClockTurntableInstrument) GetLastSecond added in v2.3.3

func (C *ClockTurntableInstrument) GetLastSecond(n uint64) uint64

GetLastSecond returns the sum of value of last n seconds

type RollingWindowCache

type RollingWindowCache interface {

	// Has
	// @Description: 判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在
	// @param key
	// @param start
	// @return uint64 start在滑动窗口内的情况,0 小于左边,1 处于窗口内,2 大于右边 ;
	// @return bool key是否存在
	// @return error
	Has(key string, start uint64) (uint64, 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

	CurrCache protocol.StoreBatcher
	// 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) (uint64, bool, error)

Has 判断 key 在 start >r.startBlockHeight条件下,在 [start,r.endBlockHeight]区间内 是否存在 @Description: @receiver r @param key @param start @return uint64 start在滑动窗口内的情况,0 小于左边,1 处于窗口内,2 大于右边 ; @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