neo-go/pkg/vm/output.go
Evgeniy Kulikov 6ccb518ab0 Optimizations + some improvements (#105)
* Optimizations + some improvements

- optimized pkg/core/storage.HeaderHashes
- optimized pkg/rpc.performRequest (used json.Encoder)
- fixes for pkg/util.ReadVarUint and pkg/util.WriteVarUint
- optimized and fix fixed8 (Fixed8DecodeString / MarshalJSON) + tests
- optimized and fix uint160 (Bytes / Uint160DecodeString / Equal / MarshalJSON) + tests
- optimized and fix uint256 (Bytes / Equal / MarshalJSON) + tests
- preallocate for pkg/vm.buildStackOutput
- add go.mod / go.sum

* update version
2018-11-26 16:56:45 +01:00

23 lines
486 B
Go

package vm
import "encoding/json"
// StackOutput holds information about the stack, used for pretty printing
// the stack.
type stackItem struct {
Value interface{} `json:"value"`
Type string `json:"type"`
}
func buildStackOutput(s *Stack) string {
items := make([]stackItem, 0, s.Len())
s.Iter(func(e *Element) {
items = append(items, stackItem{
Value: e.value,
Type: e.value.String(),
})
})
b, _ := json.MarshalIndent(items, "", " ")
return string(b)
}