rpc: move Invoke to result package

It's just a data.
This commit is contained in:
Roman Khimov 2020-01-13 12:27:34 +03:00
parent c189062f40
commit b8f7ab8e6a
2 changed files with 6 additions and 5 deletions

View file

@ -1,11 +1,12 @@
package wrappers
package result
import (
"github.com/CityOfZion/neo-go/pkg/vm"
)
// InvokeResult is used as a wrapper to represent an invokation result.
type InvokeResult struct {
// Invoke represents code invocation result and is used by several RPC calls
// that invoke functions, scripts and generic bytecode.
type Invoke struct {
State string `json:"state"`
GasConsumed string `json:"gas_consumed"`
Script string `json:"script"`

View file

@ -486,12 +486,12 @@ func (s *Server) invokescript(reqParams Params) (interface{}, error) {
// runScriptInVM runs given script in a new test VM and returns the invocation
// result.
func (s *Server) runScriptInVM(script []byte) *wrappers.InvokeResult {
func (s *Server) runScriptInVM(script []byte) *result.Invoke {
vm, _ := s.chain.GetTestVM()
vm.SetGasLimit(s.config.MaxGasInvoke)
vm.LoadScript(script)
_ = vm.Run()
result := &wrappers.InvokeResult{
result := &result.Invoke{
State: vm.State(),
GasConsumed: vm.GasConsumed().String(),
Script: hex.EncodeToString(script),