core/vm: decouple RunPrecompiled from EVM type

This commit is contained in:
Paweł Bylica 2016-12-22 15:36:13 +01:00
parent 115364b0a9
commit 4404e4bc3c
No known key found for this signature in database
GPG key ID: 7A0C037434FE77EF

View file

@ -71,7 +71,7 @@ func (evm *EVM) Run(contract *Contract, input []byte) (ret []byte, err error) {
if contract.CodeAddr != 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
}
// RunPrecompile runs and evaluate the output of a precompiled contract defined in contracts.go
func (evm *EVM) RunPrecompiled(p *PrecompiledAccount, input []byte, contract *Contract) (ret []byte, err error) {
// Runs and evaluates the output of a precompiled contract defined in contracts.go
func runPrecompiled(p *PrecompiledAccount, input []byte, contract *Contract) (ret []byte, err error) {
gas := p.Gas(len(input))
if contract.UseGas(gas) {
ret = p.Call(input)
return ret, nil
} else {
return nil, OutOfGasError