Documentation ¶
Index ¶
- Constants
- type IConsumer
- type IFreeConsumer
- type IFreeGetter
- type IGetter
- type IResourceLimiter
- type ITpsUpdater
- type ResourceLimiter
- func (s *ResourceLimiter) Consume(oldResource uint64, num uint64, preTime, now, maxStamina uint64) (bool, uint64)
- func (s *ResourceLimiter) ConsumeFree(maxFreeStamina, oldResource uint64, num uint64, preTime, now uint64) (bool, uint64)
- func (s *ResourceLimiter) GetFreeLeft(maxFreeStamina, oldResource, preTime, now uint64) (string, uint64)
- func (s *ResourceLimiter) GetStakeLeft(oldResource, preTime, now, maxStamina uint64) (string, uint64)
- func (s *ResourceLimiter) UpdateDynamicStamina(tpsInWindow, oneDayStamina, trxCount, lastUpdate, blockNum, expectedTps uint64) (uint64, uint64)
Constants ¶
View Source
const BLOCK_INTERVAL = 3
View Source
const MIN_RECOVER_DURATION = 45
recover minimum time gap
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IFreeConsumer ¶
type IFreeGetter ¶
type IResourceLimiter ¶
type IResourceLimiter interface { IConsumer IFreeConsumer IGetter IFreeGetter ITpsUpdater }
stake resource interface
func NewResourceLimiter ¶
func NewResourceLimiter() IResourceLimiter
type ITpsUpdater ¶
type ResourceLimiter ¶
type ResourceLimiter struct { }
ResourceLimiter impl all IResourceLimiter's api
func (*ResourceLimiter) ConsumeFree ¶
func (s *ResourceLimiter) ConsumeFree(maxFreeStamina, oldResource uint64, num uint64, preTime, now uint64) (bool, uint64)
FreeManager implemention
func (*ResourceLimiter) GetFreeLeft ¶
func (s *ResourceLimiter) GetFreeLeft(maxFreeStamina, oldResource, preTime, now uint64) (string, uint64)
func (*ResourceLimiter) GetStakeLeft ¶
func (s *ResourceLimiter) GetStakeLeft(oldResource, preTime, now, maxStamina uint64) (string, uint64)
func (*ResourceLimiter) UpdateDynamicStamina ¶
func (s *ResourceLimiter) UpdateDynamicStamina(tpsInWindow, oneDayStamina, trxCount, lastUpdate, blockNum, expectedTps uint64) (uint64, uint64)
Click to show internal directories.
Click to hide internal directories.