mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/vm: decouple RunPrecompiled from EVM type
This commit is contained in:
parent
115364b0a9
commit
4404e4bc3c
1 changed files with 3 additions and 4 deletions
|
|
@ -71,7 +71,7 @@ func (evm *EVM) Run(contract *Contract, input []byte) (ret []byte, err error) {
|
||||||
|
|
||||||
if contract.CodeAddr != nil {
|
if contract.CodeAddr != nil {
|
||||||
if p := Precompiled[contract.CodeAddr.Str()]; p != nil {
|
if p := Precompiled[contract.CodeAddr.Str()]; p != nil {
|
||||||
return evm.RunPrecompiled(p, input, contract)
|
return runPrecompiled(p, input, contract)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,12 +454,11 @@ func calculateGasAndSize(gasTable params.GasTable, env *Environment, contract *C
|
||||||
return newMemSize, gas, nil
|
return newMemSize, gas, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPrecompile runs and evaluate the output of a precompiled contract defined in contracts.go
|
// Runs and evaluates the output of a precompiled contract defined in contracts.go
|
||||||
func (evm *EVM) RunPrecompiled(p *PrecompiledAccount, input []byte, contract *Contract) (ret []byte, err error) {
|
func runPrecompiled(p *PrecompiledAccount, input []byte, contract *Contract) (ret []byte, err error) {
|
||||||
gas := p.Gas(len(input))
|
gas := p.Gas(len(input))
|
||||||
if contract.UseGas(gas) {
|
if contract.UseGas(gas) {
|
||||||
ret = p.Call(input)
|
ret = p.Call(input)
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, OutOfGasError
|
return nil, OutOfGasError
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue