代码拉取完成,页面将自动刷新
package vm
import (
"fmt"
"gitee.com/aiou-official/go-aiou/common"
"gitee.com/aiou-official/go-aiou/core/global"
"gitee.com/aiou-official/go-aiou/core/tx"
"gitee.com/aiou-official/go-aiou/vm/database"
"gitee.com/aiou-official/go-aiou/vm/native"
)
// CheckTxGasLimitValid ...
func CheckTxGasLimitValid(t *tx.Tx, currentGas *common.Fixed, dbVisitor *database.Visitor) (err error) {
gasLimit := &common.Fixed{Value: t.GasLimit, Decimal: 2}
if !currentGas.LessThan(gasLimit) {
return nil
}
defaultErr := fmt.Errorf("gas not enough: user %v has %v < %v", t.Publisher, currentGas.ToString(), gasLimit.ToString())
if !(len(t.Actions) == 1 && t.Actions[0].Contract == native.GasContractName && t.Actions[0].ActionName == "pledge") {
return defaultErr
}
// user is trying to pledge for gas without initial gas
args, err := UnmarshalArgs(dbVisitor.Contract(native.GasContractName).ABI("pledge"), t.Actions[0].Data)
if err != nil {
return fmt.Errorf("invalid gas pledge args %v %v", err, t.Actions[0].Data)
}
if !(args[0] == t.Publisher && args[1] == t.Publisher) {
return defaultErr
}
balance := dbVisitor.TokenBalanceFixed(global.Token, t.Publisher)
pledgeAmount, err := common.NewFixed(args[2].(string), 8)
if err != nil {
return fmt.Errorf("invalid gas pledge amount %v %v", err, args[2].(string))
}
if pledgeAmount.LessThan(database.GasMinPledgePerAction) {
return fmt.Errorf("invalid gas pledge amount %v %v", err, args[2].(string))
}
if balance.LessThan(pledgeAmount) {
return fmt.Errorf("aiou token amount not enough for pledgement %v < %v", balance.ToString(), pledgeAmount.ToString())
}
if currentGas.Add(pledgeAmount.Multiply(database.GasImmediateReward)).LessThan(gasLimit) {
return fmt.Errorf("gas not enough even if considering the new gas pledgement %v + %v < %v",
currentGas.ToString(), pledgeAmount.Multiply(database.GasImmediateReward).ToString(), gasLimit.ToString())
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。