mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-25 03:56:34 +00:00
6ccb518ab0
* 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
23 lines
486 B
Go
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)
|
|
}
|