From b8f7ab8e6a6fce13d59ffc6a5c36c4a4e763fe12 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 13 Jan 2020 12:27:34 +0300 Subject: [PATCH] rpc: move Invoke to result package It's just a data. --- pkg/rpc/{wrappers/invoke_result.go => result/invoke.go} | 7 ++++--- pkg/rpc/server.go | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) rename pkg/rpc/{wrappers/invoke_result.go => result/invoke.go} (52%) diff --git a/pkg/rpc/wrappers/invoke_result.go b/pkg/rpc/result/invoke.go similarity index 52% rename from pkg/rpc/wrappers/invoke_result.go rename to pkg/rpc/result/invoke.go index 4cc790bf5..f79d4d365 100644 --- a/pkg/rpc/wrappers/invoke_result.go +++ b/pkg/rpc/result/invoke.go @@ -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"` diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index 47f186c9d..ae8b87a00 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -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),