mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 05:41:35 +00:00
internal/ethapi: refactor func ToMessage for CallArgs
This commit is contained in:
parent
1b2d023da2
commit
45e57e41b4
2 changed files with 7 additions and 6 deletions
|
|
@ -778,3 +778,8 @@ func (m Message) CheckNonce() bool { return m.checkNonce }
|
|||
func (m Message) AccessList() AccessList { return m.accessList }
|
||||
|
||||
func (m *Message) SetNonce(nonce uint64) { m.nonce = nonce }
|
||||
|
||||
func (m *Message) SetBalanceTokenFeeForCall() {
|
||||
m.balanceTokenFee = new(big.Int).SetUint64(m.gasLimit)
|
||||
m.balanceTokenFee.Mul(m.balanceTokenFee, m.gasPrice)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1249,7 +1249,6 @@ type CallArgs struct {
|
|||
}
|
||||
|
||||
// ToMessage converts CallArgs to the Message type used by the core evm
|
||||
// TODO: set balanceTokenFee
|
||||
func (args *CallArgs) ToMessage(b Backend, number *big.Int, globalGasCap uint64) types.Message {
|
||||
// Set sender address or use a default if none specified
|
||||
var addr common.Address
|
||||
|
|
@ -1298,11 +1297,7 @@ func (args *CallArgs) ToMessage(b Backend, number *big.Int, globalGasCap uint64)
|
|||
accessList = *args.AccessList
|
||||
}
|
||||
|
||||
balanceTokenFee := big.NewInt(0).SetUint64(gas)
|
||||
balanceTokenFee = balanceTokenFee.Mul(balanceTokenFee, gasPrice)
|
||||
|
||||
// Create new call message
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false, balanceTokenFee, number)
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false, nil, number)
|
||||
return msg
|
||||
}
|
||||
|
||||
|
|
@ -1321,6 +1316,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
|
|||
}
|
||||
|
||||
msg := args.ToMessage(b, header.Number, globalGasCap)
|
||||
msg.SetBalanceTokenFeeForCall()
|
||||
|
||||
// Setup context so it may be cancelled the call has completed
|
||||
// or, in case of unmetered gas, setup a context with a timeout.
|
||||
|
|
|
|||
Loading…
Reference in a new issue