utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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 IConsumer

type IConsumer interface {
	Consume(oldResource, num, preTime, now, maxStamina uint64) (bool, uint64)
}

type IFreeConsumer

type IFreeConsumer interface {
	ConsumeFree(maxFreeStamina, oldResource, num, preTime, now uint64) (bool, uint64)
}

type IFreeGetter

type IFreeGetter interface {
	GetFreeLeft(maxFreeStamina, oldResource, preTime, now uint64) (string, uint64)
}

type IGetter

type IGetter interface {
	GetStakeLeft(oldResource, preTime, now, maxStamina uint64) (string, uint64)
}

type IResourceLimiter

type IResourceLimiter interface {
	IConsumer
	IFreeConsumer
	IGetter
	IFreeGetter
	ITpsUpdater
}

stake resource interface

func NewResourceLimiter

func NewResourceLimiter() IResourceLimiter

type ITpsUpdater

type ITpsUpdater interface {
	UpdateDynamicStamina(tpsInWindow, oneDayStamina, trxCount, lastUpdate, blockNum, expectedTps uint64) (uint64, uint64)
}

type ResourceLimiter

type ResourceLimiter struct {
}

ResourceLimiter impl all IResourceLimiter's api

func (*ResourceLimiter) Consume

func (s *ResourceLimiter) Consume(oldResource uint64, num uint64, preTime, now, maxStamina uint64) (bool, uint64)

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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