mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
smartcontract: turn trigger types into Type
1) Turn trigger types from byte constants into Type 2) Add auto-generated stringer for future purposes
This commit is contained in:
parent
b3621d4a86
commit
7d46404e2d
6 changed files with 98 additions and 11 deletions
|
@ -1688,6 +1688,6 @@ func (bc *Blockchain) secondsPerBlock() int {
|
|||
return bc.config.SecondsPerBlock
|
||||
}
|
||||
|
||||
func (bc *Blockchain) newInteropContext(trigger byte, s storage.Store, block *block.Block, tx *transaction.Transaction) *interopContext {
|
||||
func (bc *Blockchain) newInteropContext(trigger trigger.Type, s storage.Store, block *block.Block, tx *transaction.Transaction) *interopContext {
|
||||
return newInteropContext(trigger, bc, s, block, tx, bc.log)
|
||||
}
|
||||
|
|
|
@ -14,13 +14,14 @@ import (
|
|||
"github.com/CityOfZion/neo-go/pkg/core/state"
|
||||
"github.com/CityOfZion/neo-go/pkg/core/storage"
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/smartcontract/trigger"
|
||||
"github.com/CityOfZion/neo-go/pkg/vm"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type interopContext struct {
|
||||
bc Blockchainer
|
||||
trigger byte
|
||||
trigger trigger.Type
|
||||
block *block.Block
|
||||
tx *transaction.Transaction
|
||||
dao *cachedDao
|
||||
|
@ -28,7 +29,7 @@ type interopContext struct {
|
|||
log *zap.Logger
|
||||
}
|
||||
|
||||
func newInteropContext(trigger byte, bc Blockchainer, s storage.Store, block *block.Block, tx *transaction.Transaction, log *zap.Logger) *interopContext {
|
||||
func newInteropContext(trigger trigger.Type, bc Blockchainer, s storage.Store, block *block.Block, tx *transaction.Transaction, log *zap.Logger) *interopContext {
|
||||
dao := newCachedDao(s)
|
||||
nes := make([]state.NotificationEvent, 0)
|
||||
return &interopContext{bc, trigger, block, tx, dao, nes, log}
|
||||
|
|
|
@ -2,6 +2,7 @@ package state
|
|||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/smartcontract/trigger"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/CityOfZion/neo-go/pkg/vm"
|
||||
)
|
||||
|
@ -17,7 +18,7 @@ type NotificationEvent struct {
|
|||
// all resulting notifications, state, stack and other metadata.
|
||||
type AppExecResult struct {
|
||||
TxHash util.Uint256
|
||||
Trigger byte
|
||||
Trigger trigger.Type
|
||||
VMState string
|
||||
GasConsumed util.Fixed8
|
||||
Stack string // JSON
|
||||
|
@ -39,7 +40,7 @@ func (ne *NotificationEvent) DecodeBinary(r *io.BinReader) {
|
|||
// EncodeBinary implements the Serializable interface.
|
||||
func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteBytes(aer.TxHash[:])
|
||||
w.WriteB(aer.Trigger)
|
||||
w.WriteB(byte(aer.Trigger))
|
||||
w.WriteString(aer.VMState)
|
||||
aer.GasConsumed.EncodeBinary(w)
|
||||
w.WriteString(aer.Stack)
|
||||
|
@ -49,7 +50,7 @@ func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
|
|||
// DecodeBinary implements the Serializable interface.
|
||||
func (aer *AppExecResult) DecodeBinary(r *io.BinReader) {
|
||||
r.ReadBytes(aer.TxHash[:])
|
||||
aer.Trigger = r.ReadB()
|
||||
aer.Trigger = trigger.Type(r.ReadB())
|
||||
aer.VMState = r.ReadString()
|
||||
aer.GasConsumed.DecodeBinary(r)
|
||||
aer.Stack = r.ReadString()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue