rename tx throttline configuration key name to MaxNumTxsPerAccountPastHourLimit

pull/1319/head
Dennis Won 5 years ago
parent c001915e1a
commit df2f2eb3c9
  1. 6
      internal/configs/sharding/fixedschedule.go
  2. 8
      internal/configs/sharding/localnet.go
  3. 8
      internal/configs/sharding/mainnet.go
  4. 6
      internal/configs/sharding/shardingconfig.go
  5. 8
      internal/configs/sharding/testnet.go
  6. 4
      node/worker/worker.go

@ -40,8 +40,8 @@ func (s fixedSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt return amountBigInt
} }
func (s fixedSchedule) MaxTxsPerAccountInBlockLimit() uint64 { func (s fixedSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return mainnetMaxTxsPerAccountInBlockLimit return mainnetMaxNumTxsPerAccountPastHourLimit
} }
func (s fixedSchedule) MaxTxsPerBlockLimit() int { func (s fixedSchedule) MaxTxsPerBlockLimit() int {
@ -51,7 +51,7 @@ func (s fixedSchedule) MaxTxsPerBlockLimit() int {
func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig { func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{ return &TxsThrottleConfig{
MaxTxAmountLimit: s.MaxTxAmountLimit(), MaxTxAmountLimit: s.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: s.MaxTxsPerAccountInBlockLimit(), MaxNumTxsPerAccountPastHourLimit: s.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(), MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(),
} }
} }

@ -21,7 +21,7 @@ const (
twoOne = 5 twoOne = 5
localnetMaxTxAmountLimit = 1e2 // unit is in One localnetMaxTxAmountLimit = 1e2 // unit is in One
localnetMaxTxsPerAccountInBlockLimit = 2 localnetMaxNumTxsPerAccountPastHourLimit = 2
localnetMaxTxsPerBlockLimit = 8000 localnetMaxTxsPerBlockLimit = 8000
) )
@ -68,8 +68,8 @@ func (ls localnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt return amountBigInt
} }
func (ls localnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 { func (ls localnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return localnetMaxTxsPerAccountInBlockLimit return localnetMaxNumTxsPerAccountPastHourLimit
} }
func (ls localnetSchedule) MaxTxsPerBlockLimit() int { func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
@ -79,7 +79,7 @@ func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig { func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{ return &TxsThrottleConfig{
MaxTxAmountLimit: ls.MaxTxAmountLimit(), MaxTxAmountLimit: ls.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ls.MaxTxsPerAccountInBlockLimit(), MaxNumTxsPerAccountPastHourLimit: ls.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(), MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(),
} }
} }

@ -17,7 +17,7 @@ const (
mainnetV0_4Epoch = 10 mainnetV0_4Epoch = 10
mainnetMaxTxAmountLimit = 1e3 // unit is in One mainnetMaxTxAmountLimit = 1e3 // unit is in One
mainnetMaxTxsPerAccountInBlockLimit = 10 mainnetMaxNumTxsPerAccountPastHourLimit = 10
mainnetMaxTxsPerBlockLimit = 8000 mainnetMaxTxsPerBlockLimit = 8000
) )
@ -77,8 +77,8 @@ func (ms mainnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt return amountBigInt
} }
func (ms mainnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 { func (ms mainnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return mainnetMaxTxsPerAccountInBlockLimit return mainnetMaxNumTxsPerAccountPastHourLimit
} }
func (ms mainnetSchedule) MaxTxsPerBlockLimit() int { func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
@ -88,7 +88,7 @@ func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig { func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{ return &TxsThrottleConfig{
MaxTxAmountLimit: ms.MaxTxAmountLimit(), MaxTxAmountLimit: ms.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ms.MaxTxsPerAccountInBlockLimit(), MaxNumTxsPerAccountPastHourLimit: ms.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ms.MaxTxsPerBlockLimit(), MaxTxsPerBlockLimit: ms.MaxTxsPerBlockLimit(),
} }
} }

@ -26,7 +26,7 @@ type Schedule interface {
MaxTxAmountLimit() *big.Int MaxTxAmountLimit() *big.Int
// Max number of transactions of a particular account per block level // Max number of transactions of a particular account per block level
MaxTxsPerAccountInBlockLimit() uint64 MaxNumTxsPerAccountPastHourLimit() uint64
// Max total number of transactions in a block // Max total number of transactions in a block
MaxTxsPerBlockLimit() int MaxTxsPerBlockLimit() int
@ -87,8 +87,8 @@ type TxsThrottleConfig struct {
// Max amount limit for a valid transaction // Max amount limit for a valid transaction
MaxTxAmountLimit *big.Int MaxTxAmountLimit *big.Int
// Max number of transactions of a particular account per block level // Max number of transactions of a particular account for the past hour
MaxTxsPerAccountInBlockLimit uint64 MaxNumTxsPerAccountPastHourLimit uint64
// Max total number of transactions in a block // Max total number of transactions in a block
MaxTxsPerBlockLimit int MaxTxsPerBlockLimit int

@ -21,7 +21,7 @@ const (
threeOne = 111 threeOne = 111
testnetMaxTxAmountLimit = 1e3 // unit is in One testnetMaxTxAmountLimit = 1e3 // unit is in One
testnetMaxTxsPerAccountInBlockLimit = 10 testnetMaxNumTxsPerAccountPastHourLimit = 10
testnetMaxTxsPerBlockLimit = 8000 testnetMaxTxsPerBlockLimit = 8000
) )
@ -69,8 +69,8 @@ func (ts testnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt return amountBigInt
} }
func (ts testnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 { func (ts testnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return testnetMaxTxsPerAccountInBlockLimit return testnetMaxNumTxsPerAccountPastHourLimit
} }
func (ts testnetSchedule) MaxTxsPerBlockLimit() int { func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
@ -80,7 +80,7 @@ func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig { func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{ return &TxsThrottleConfig{
MaxTxAmountLimit: ts.MaxTxAmountLimit(), MaxTxAmountLimit: ts.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ts.MaxTxsPerAccountInBlockLimit(), MaxNumTxsPerAccountPastHourLimit: ts.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ts.MaxTxsPerBlockLimit(), MaxTxsPerBlockLimit: ts.MaxTxsPerBlockLimit(),
} }
} }

@ -86,9 +86,9 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
for _, blockTxsCounts := range recentTxsStats { for _, blockTxsCounts := range recentTxsStats {
numTxsPastHour += blockTxsCounts[sender] numTxsPastHour += blockTxsCounts[sender]
} }
if numTxsPastHour >= (*txsThrottleConfig).MaxTxsPerAccountInBlockLimit { if numTxsPastHour >= (*txsThrottleConfig).MaxNumTxsPerAccountPastHourLimit {
utils.Logger().Debug(). utils.Logger().Debug().
Uint64("MaxTxsPerAccountInBlockLimit", (*txsThrottleConfig).MaxTxsPerAccountInBlockLimit). Uint64("MaxNumTxsPerAccountPastHourLimit", (*txsThrottleConfig).MaxNumTxsPerAccountPastHourLimit).
Msg("Throttling tx with max txs per account in a single block limit") Msg("Throttling tx with max txs per account in a single block limit")
return sender, shardingconfig.Unselect return sender, shardingconfig.Unselect
} }

Loading…
Cancel
Save