neoneo-go/pkg/core/state/notification_event.go
Roman Khimov 8b3080b972 io: rename Read/WriteBytes to Read/WriteB
go vet is not happy about them:
  pkg/io/binaryReader.go:92:21: method ReadByte() byte should have signature ReadByte() (byte, error)
  pkg/io/binaryWriter.go:75:21: method WriteByte(u8 byte) should have signature WriteByte(byte) error
2019-12-12 20:19:50 +03:00

57 lines
1.6 KiB
Go

package state
import (
"github.com/CityOfZion/neo-go/pkg/io"
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/CityOfZion/neo-go/pkg/vm"
)
// NotificationEvent is a tuple of scripthash that emitted the StackItem as a
// notification and that item itself.
type NotificationEvent struct {
ScriptHash util.Uint160
Item vm.StackItem
}
// AppExecResult represent the result of the script execution, gathering together
// all resulting notifications, state, stack and other metadata.
type AppExecResult struct {
TxHash util.Uint256
Trigger byte
VMState string
GasConsumed util.Fixed8
Stack string // JSON
Events []NotificationEvent
}
// EncodeBinary implements the Serializable interface.
func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(ne.ScriptHash[:])
vm.EncodeBinaryStackItem(ne.Item, w)
}
// DecodeBinary implements the Serializable interface.
func (ne *NotificationEvent) DecodeBinary(r *io.BinReader) {
r.ReadBytes(ne.ScriptHash[:])
ne.Item = vm.DecodeBinaryStackItem(r)
}
// EncodeBinary implements the Serializable interface.
func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(aer.TxHash[:])
w.WriteB(aer.Trigger)
w.WriteString(aer.VMState)
aer.GasConsumed.EncodeBinary(w)
w.WriteString(aer.Stack)
w.WriteArray(aer.Events)
}
// DecodeBinary implements the Serializable interface.
func (aer *AppExecResult) DecodeBinary(r *io.BinReader) {
r.ReadBytes(aer.TxHash[:])
aer.Trigger = r.ReadB()
aer.VMState = r.ReadString()
aer.GasConsumed.DecodeBinary(r)
aer.Stack = r.ReadString()
r.ReadArray(&aer.Events)
}