quota

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QuotaParamTest    = NewQuotaParams("4.200604096e-21", "6.40975486e-07")
	QuotaParamMainNet = NewQuotaParams("4.200627522e-24", "6.259419649e-10")
)

Functions

func CalcCreateQuota

func CalcCreateQuota(fee *big.Int) uint64

func CalcPoWDifficulty added in v1.3.0

func CalcPoWDifficulty(quotaRequired uint64) *big.Int

func CalcQuota

func CalcQuota(db quotaDb, addr types.Address, pledgeAmount *big.Int, difficulty *big.Int) (quotaTotal uint64, quotaAddition uint64, err error)

quotaInit = quotaLimitForAccount * (1 - 2/(1 + e**(fDifficulty * difficulty + fPledge * snapshotHeightGap * pledgeAmount)))

  • quota used by prevBlock referring to the same snapshot hash

quotaAddition = quotaLimitForAccount * (1 - 2/(1 + e**(fDifficulty * difficulty + fPledge * snapshotHeightGap * pledgeAmount)))

  • quotaLimitForAccount * (1 - 2/(1 + e**(fPledge * snapshotHeightGap * pledgeAmount)))

snapshotHeightGap is limit to 1 day e**(fDifficulty * difficulty + fPledge * snapshotHeightGap * pledgeAmount) is discrete to reduce computation complexity quotaLimitForAccount is within a range decided by net congestion and net capacity user account gets extra quota to send or receive a transaction if calc PoW, extra quota is decided by difficulty contract account only gets quota via pledge user account genesis block(a receive block) must calculate a PoW to get quota

func CalcQuotaV2

func CalcQuotaV2(db quotaDb, addr types.Address, pledgeAmount *big.Int, difficulty *big.Int) (uint64, uint64, error)

func CanPoW added in v1.3.0

func CanPoW(db quotaDb, addr types.Address) bool

func CheckPoWLimit added in v1.3.0

func CheckPoWLimit(db quotaDb) (bool, error)

A single account is limited to send 10 tx with PoW in one day

func GetPledgeQuota

func GetPledgeQuota(db quotaDb, beneficial types.Address, pledgeAmount *big.Int) (uint64, error)

func InitQuotaConfig

func InitQuotaConfig(isTestParam bool)

func IsPoW

func IsPoW(nonce []byte) bool

Types

type NodeConfig

type NodeConfig struct {
	QuotaParams
	// contains filtered or unexported fields
}

type QuotaParams

type QuotaParams struct {
	// contains filtered or unexported fields
}

func NewQuotaParams

func NewQuotaParams(strA, strB string) QuotaParams

Jump to

Keyboard shortcuts

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