Merge pull request #271 from nguyenbatam/limit_max_nonce_transaction_in_queue

limit max threshold nonce in queue
This commit is contained in:
Tuna 2018-11-10 10:54:07 +07:00 committed by GitHub
commit 046ed99c12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View file

@ -1,16 +1,17 @@
package common package common
const ( const (
RewardMasterPercent = 40 RewardMasterPercent = 40
RewardVoterPercent = 50 RewardVoterPercent = 50
RewardFoundationPercent = 10 RewardFoundationPercent = 10
HexSignMethod = "e341eaa4" HexSignMethod = "e341eaa4"
HexSetSecret = "34d38600" HexSetSecret = "34d38600"
HexSetOpening = "e11f5ba2" HexSetOpening = "e11f5ba2"
EpocBlockSecret = 800 EpocBlockSecret = 800
EpocBlockOpening = 850 EpocBlockOpening = 850
EpocBlockRandomize = 900 EpocBlockRandomize = 900
MaxMasternodes = 150 MaxMasternodes = 150
LimitPenaltyEpoch = 4 LimitPenaltyEpoch = 4
BlocksPerYear = uint64(15768000) BlocksPerYear = uint64(15768000)
LimitThresholdNonceInQueue = 10
) )

View file

@ -600,6 +600,9 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if pool.currentState.GetNonce(from) > tx.Nonce() { if pool.currentState.GetNonce(from) > tx.Nonce() {
return ErrNonceTooLow return ErrNonceTooLow
} }
if pool.pendingState.GetNonce(from)+common.LimitThresholdNonceInQueue < tx.Nonce() {
return ErrNonceTooHigh
}
// Transactor should have enough funds to cover the costs // Transactor should have enough funds to cover the costs
// cost == V + GP * GL // cost == V + GP * GL
if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 { if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 {