forked from TrueCloudLab/neoneo-go
core: refactor checkBalanceAndUpdate
This commit is contained in:
parent
1fa2d4bc6a
commit
4be1009def
1 changed files with 8 additions and 5 deletions
|
@ -124,11 +124,14 @@ func (mp *Pool) checkBalanceAndUpdate(tx *transaction.Transaction, feer Feer) bo
|
||||||
senderFee.balance = feer.GetUtilityTokenBalance(tx.Sender)
|
senderFee.balance = feer.GetUtilityTokenBalance(tx.Sender)
|
||||||
mp.fees[tx.Sender] = senderFee
|
mp.fees[tx.Sender] = senderFee
|
||||||
}
|
}
|
||||||
needFee := senderFee.feeSum + tx.SystemFee + tx.NetworkFee
|
return checkBalance(tx, senderFee)
|
||||||
if senderFee.balance.Cmp(big.NewInt(needFee)) < 0 {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
|
// checkBalance returns true in case when sender has enough GAS to pay for the
|
||||||
|
// transaction
|
||||||
|
func checkBalance(tx *transaction.Transaction, balance utilityBalanceAndFees) bool {
|
||||||
|
needFee := balance.feeSum + tx.SystemFee + tx.NetworkFee
|
||||||
|
return balance.balance.Cmp(big.NewInt(needFee)) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// addSendersFee adds system fee and network fee to the total sender`s fee in mempool
|
// addSendersFee adds system fee and network fee to the total sender`s fee in mempool
|
||||||
|
|
Loading…
Reference in a new issue