forked from TrueCloudLab/neoneo-go
parent
6ac69d075e
commit
6ed2bd63b9
5 changed files with 20 additions and 22 deletions
|
@ -29,7 +29,7 @@ import (
|
|||
// Tuning parameters.
|
||||
const (
|
||||
headerBatchCount = 2000
|
||||
version = "0.0.8"
|
||||
version = "0.0.9"
|
||||
|
||||
// This one comes from C# code and it's different from the constant used
|
||||
// when creating an asset with Neo.Asset.Create interop call. It looks
|
||||
|
@ -708,7 +708,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
|
|||
Trigger: trigger.Application,
|
||||
VMState: v.State(),
|
||||
GasConsumed: v.GasConsumed(),
|
||||
Stack: v.Stack("estack"),
|
||||
Stack: v.Estack().ToContractParameters(),
|
||||
Events: systemInterop.notifications,
|
||||
}
|
||||
err = cache.PutAppExecResult(aer)
|
||||
|
|
|
@ -171,7 +171,11 @@ func TestGetValidators(t *testing.T) {
|
|||
func TestPutGetAppExecResult(t *testing.T) {
|
||||
dao := newDao(storage.NewMemoryStore())
|
||||
hash := random.Uint256()
|
||||
appExecResult := &state.AppExecResult{TxHash: hash, Events: []state.NotificationEvent{}}
|
||||
appExecResult := &state.AppExecResult{
|
||||
TxHash: hash,
|
||||
Events: []state.NotificationEvent{},
|
||||
Stack: []smartcontract.Parameter{},
|
||||
}
|
||||
err := dao.PutAppExecResult(appExecResult)
|
||||
require.NoError(t, err)
|
||||
gotAppExecResult, err := dao.GetAppExecResult(hash)
|
||||
|
|
|
@ -2,6 +2,7 @@ package state
|
|||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
|
@ -21,7 +22,7 @@ type AppExecResult struct {
|
|||
Trigger trigger.Type
|
||||
VMState string
|
||||
GasConsumed util.Fixed8
|
||||
Stack string // JSON
|
||||
Stack []smartcontract.Parameter
|
||||
Events []NotificationEvent
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,7 @@ func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
|
|||
w.WriteB(byte(aer.Trigger))
|
||||
w.WriteString(aer.VMState)
|
||||
aer.GasConsumed.EncodeBinary(w)
|
||||
w.WriteString(aer.Stack)
|
||||
w.WriteArray(aer.Stack)
|
||||
w.WriteArray(aer.Events)
|
||||
}
|
||||
|
||||
|
@ -53,6 +54,6 @@ func (aer *AppExecResult) DecodeBinary(r *io.BinReader) {
|
|||
aer.Trigger = trigger.Type(r.ReadB())
|
||||
aer.VMState = r.ReadString()
|
||||
aer.GasConsumed.DecodeBinary(r)
|
||||
aer.Stack = r.ReadString()
|
||||
r.ReadArray(&aer.Stack)
|
||||
r.ReadArray(&aer.Events)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -30,7 +31,7 @@ func TestEncodeDecodeAppExecResult(t *testing.T) {
|
|||
Trigger: 1,
|
||||
VMState: "Hault",
|
||||
GasConsumed: 10,
|
||||
Stack: "",
|
||||
Stack: []smartcontract.Parameter{},
|
||||
Events: []NotificationEvent{},
|
||||
}
|
||||
buf := io.NewBufBinWriter()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package result
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
@ -18,12 +16,12 @@ type ApplicationLog struct {
|
|||
|
||||
// Execution response wrapper
|
||||
type Execution struct {
|
||||
Trigger string `json:"trigger"`
|
||||
ScriptHash util.Uint160 `json:"contract"`
|
||||
VMState string `json:"vmstate"`
|
||||
GasConsumed util.Fixed8 `json:"gas_consumed"`
|
||||
Stack json.RawMessage `json:"stack"`
|
||||
Events []NotificationEvent `json:"notifications"`
|
||||
Trigger string `json:"trigger"`
|
||||
ScriptHash util.Uint160 `json:"contract"`
|
||||
VMState string `json:"vmstate"`
|
||||
GasConsumed util.Fixed8 `json:"gas_consumed"`
|
||||
Stack []smartcontract.Parameter `json:"stack"`
|
||||
Events []NotificationEvent `json:"notifications"`
|
||||
}
|
||||
|
||||
//NotificationEvent response wrapper
|
||||
|
@ -46,18 +44,12 @@ func NewApplicationLog(appExecRes *state.AppExecResult, scriptHash util.Uint160)
|
|||
|
||||
triggerString := appExecRes.Trigger.String()
|
||||
|
||||
var rawStack json.RawMessage
|
||||
if len(appExecRes.Stack) != 0 {
|
||||
rawStack = json.RawMessage(appExecRes.Stack)
|
||||
} else {
|
||||
rawStack = json.RawMessage("[]")
|
||||
}
|
||||
executions := []Execution{{
|
||||
Trigger: triggerString,
|
||||
ScriptHash: scriptHash,
|
||||
VMState: appExecRes.VMState,
|
||||
GasConsumed: appExecRes.GasConsumed,
|
||||
Stack: rawStack,
|
||||
Stack: appExecRes.Stack,
|
||||
Events: events,
|
||||
}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue