limit max threshold nonce in queue

This commit is contained in:
Nguyen Ba Tam 2018-11-10 10:42:46 +07:00
parent b360290ded
commit 2006e3240a
2 changed files with 16 additions and 12 deletions

View file

@ -13,4 +13,5 @@ const (
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 {