execution_tx

package
v0.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TxType_name = map[int32]string{
		0: "TxType_INVALID",
		1: "TxType_START",
		2: "TxType_SET_OUTPUTS",
		3: "TxType_COMPLETE",
		4: "TxType_APPEND_LOG",
	}
	TxType_value = map[string]int32{
		"TxType_INVALID":     0,
		"TxType_START":       1,
		"TxType_SET_OUTPUTS": 2,
		"TxType_COMPLETE":    3,
		"TxType_APPEND_LOG":  4,
	}
)

Enum value maps for TxType.

View Source
var ObjectOperationTypeID = "forge/execution/tx"

ObjectOperationTypeID is the transaction object operation type id.

Functions

func LookupWorldOp

func LookupWorldOp(ctx context.Context, opTypeID string) (world.Operation, error)

LookupWorldOp performs the lookup operation for the pass op types.

Types

type Transaction

type Transaction interface {
	// MarshalVT marshals to binary.
	MarshalVT() ([]byte, error)
	// UnmarshalVT unmarshals from binary.
	UnmarshalVT(data []byte) error

	// GetTxType returns the type of transaction this is.
	GetTxType() TxType
	// Validate performs a cursory check of the transaction.
	// Note: this should not fetch network data.
	Validate() error
	// ExecuteTx executes the transaction against the execution instance.
	// exCursor should be located at the execution state root.
	// The result is written into exCursor.
	ExecuteTx(
		ctx context.Context,
		sender peer.ID,
		exCursor *block.Cursor,
		root *forge_execution.Execution,
	) error
}

Transaction is an instance of a transaction object.

func NewTxCompleteTxn

func NewTxCompleteTxn() Transaction

NewTxCompleteTxn constructs the COMPLETE transaction.

func NewTxSetOutputsTxn

func NewTxSetOutputsTxn() Transaction

NewTxSetOutputsTxn constructs a new SET_OUTPUTS transaction.

func NewTxStartTxn

func NewTxStartTxn() Transaction

NewTxStartTxn constructs a new START transaction.

type Tx

type Tx struct {

	// TxType is the kind of transaction this is.
	TxType TxType `protobuf:"varint,1,opt,name=tx_type,json=txType,proto3" json:"txType,omitempty"`
	// TxStart contains the start transaction tx.
	// TxType_INVALID
	TxStart *TxStart `protobuf:"bytes,2,opt,name=tx_start,json=txStart,proto3" json:"txStart,omitempty"`
	// TxSetOutputs contains the set outputs tx.
	// TxType_SET_OUTPUTS
	TxSetOutputs *TxSetOutputs `protobuf:"bytes,3,opt,name=tx_set_outputs,json=txSetOutputs,proto3" json:"txSetOutputs,omitempty"`
	// TxComplete contains the complete tx.
	// TxType_COMPLETE
	TxComplete *TxComplete `protobuf:"bytes,4,opt,name=tx_complete,json=txComplete,proto3" json:"txComplete,omitempty"`
	// TxAppendLog contains the append log tx.
	// TxType_APPEND_LOG
	TxAppendLog *TxAppendLog `protobuf:"bytes,5,opt,name=tx_append_log,json=txAppendLog,proto3" json:"txAppendLog,omitempty"`
	// contains filtered or unexported fields
}

Tx is the on-the-wire representation of a transaction.

func ByteSliceToTx

func ByteSliceToTx(blk block.Block) (*Tx, error)

ByteSliceToTx converts a byte slice block a Tx. If blk is nil, returns nil, nil If the blk is already parsed to a MockWorldOp, returns the MockWorldOp.

func NewTxAppendLog

func NewTxAppendLog(entries []*forge_execution.LogEntry) (*Tx, error)

NewTxAppendLog constructs an APPEND_LOG transaction. Clones the entries when building the Tx object.

func NewTxComplete

func NewTxComplete(result *forge_value.Result) *Tx

NewTxComplete constructs the COMPLETE transaction.

func NewTxSetOutputs

func NewTxSetOutputs(outputs forge_value.ValueSlice, clearOld bool) (*Tx, error)

NewTxSetOutputs constructs a new SET_OUTPUTS transaction. clones the ValueSet when building the Tx object.

func NewTxStart

func NewTxStart(peerID peer.ID) *Tx

NewTxStart constructs a new START transaction.

func (*Tx) ApplyWorldObjectOp

func (t *Tx) ApplyWorldObjectOp(
	ctx context.Context,
	le *logrus.Entry,
	objectHandle world.ObjectState,
	sender peer.ID,
) (sysErr bool, err error)

ApplyWorldObjectOp applies the operation to a world object handle.

func (*Tx) ApplyWorldOp

func (t *Tx) ApplyWorldOp(
	ctx context.Context,
	le *logrus.Entry,
	worldHandle world.WorldState,
	sender peer.ID,
) (sysErr bool, err error)

ApplyWorldOp applies the operation as a world operation. returns false, ErrUnhandledOp if the operation cannot handle a world op

func (*Tx) CloneMessageVT

func (m *Tx) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Tx) CloneVT

func (m *Tx) CloneVT() *Tx

func (*Tx) EqualMessageVT

func (this *Tx) EqualMessageVT(thatMsg any) bool

func (*Tx) EqualVT

func (this *Tx) EqualVT(that *Tx) bool

func (*Tx) GetOperationTypeId

func (t *Tx) GetOperationTypeId() string

GetOperationTypeId returns the operation type identifier.

func (*Tx) GetTxAppendLog

func (x *Tx) GetTxAppendLog() *TxAppendLog

func (*Tx) GetTxComplete

func (x *Tx) GetTxComplete() *TxComplete

func (*Tx) GetTxSetOutputs

func (x *Tx) GetTxSetOutputs() *TxSetOutputs

func (*Tx) GetTxStart

func (x *Tx) GetTxStart() *TxStart

func (*Tx) GetTxType

func (x *Tx) GetTxType() TxType

func (*Tx) LocateTx

func (t *Tx) LocateTx() (Transaction, error)

LocateTx returns the sub-block for the transaction.

func (*Tx) MarshalBlock

func (t *Tx) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Tx) MarshalJSON

func (x *Tx) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Tx to JSON.

func (*Tx) MarshalProtoJSON

func (x *Tx) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Tx message to JSON.

func (*Tx) MarshalProtoText

func (x *Tx) MarshalProtoText() string

func (*Tx) MarshalToSizedBufferVT

func (m *Tx) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Tx) MarshalToVT

func (m *Tx) MarshalToVT(dAtA []byte) (int, error)

func (*Tx) MarshalVT

func (m *Tx) MarshalVT() (dAtA []byte, err error)

func (*Tx) ProtoMessage

func (*Tx) ProtoMessage()

func (*Tx) Reset

func (x *Tx) Reset()

func (*Tx) SizeVT

func (m *Tx) SizeVT() (n int)

func (*Tx) String

func (x *Tx) String() string

func (*Tx) UnmarshalBlock

func (t *Tx) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Tx) UnmarshalJSON

func (x *Tx) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Tx from JSON.

func (*Tx) UnmarshalProtoJSON

func (x *Tx) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Tx message from JSON.

func (*Tx) UnmarshalVT

func (m *Tx) UnmarshalVT(dAtA []byte) error

func (*Tx) Validate

func (t *Tx) Validate() error

Validate checks the tx.

type TxAppendLog

type TxAppendLog struct {

	// Entries is the set of log entries to append.
	Entries []*execution.LogEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

TxAppendLog appends log entries to the execution. Execution must be in the RUNNING state. Sender must be the peer_id specified on the Execution. TxType: TxType_APPEND_LOG

func (*TxAppendLog) CloneMessageVT

func (m *TxAppendLog) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TxAppendLog) CloneVT

func (m *TxAppendLog) CloneVT() *TxAppendLog

func (*TxAppendLog) EqualMessageVT

func (this *TxAppendLog) EqualMessageVT(thatMsg any) bool

func (*TxAppendLog) EqualVT

func (this *TxAppendLog) EqualVT(that *TxAppendLog) bool

func (*TxAppendLog) ExecuteTx

func (t *TxAppendLog) ExecuteTx(
	ctx context.Context,
	sender peer.ID,
	exCursor *block.Cursor,
	root *forge_execution.Execution,
) error

ExecuteTx executes the transaction against the execution instance.

func (*TxAppendLog) GetEntries

func (x *TxAppendLog) GetEntries() []*execution.LogEntry

func (*TxAppendLog) GetTxType

func (t *TxAppendLog) GetTxType() TxType

GetTxType returns the type of transaction this is.

func (*TxAppendLog) MarshalJSON

func (x *TxAppendLog) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TxAppendLog to JSON.

func (*TxAppendLog) MarshalProtoJSON

func (x *TxAppendLog) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TxAppendLog message to JSON.

func (*TxAppendLog) MarshalProtoText

func (x *TxAppendLog) MarshalProtoText() string

func (*TxAppendLog) MarshalToSizedBufferVT

func (m *TxAppendLog) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TxAppendLog) MarshalToVT

func (m *TxAppendLog) MarshalToVT(dAtA []byte) (int, error)

func (*TxAppendLog) MarshalVT

func (m *TxAppendLog) MarshalVT() (dAtA []byte, err error)

func (*TxAppendLog) ProtoMessage

func (*TxAppendLog) ProtoMessage()

func (*TxAppendLog) Reset

func (x *TxAppendLog) Reset()

func (*TxAppendLog) SizeVT

func (m *TxAppendLog) SizeVT() (n int)

func (*TxAppendLog) String

func (x *TxAppendLog) String() string

func (*TxAppendLog) UnmarshalJSON

func (x *TxAppendLog) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TxAppendLog from JSON.

func (*TxAppendLog) UnmarshalProtoJSON

func (x *TxAppendLog) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TxAppendLog message from JSON.

func (*TxAppendLog) UnmarshalVT

func (m *TxAppendLog) UnmarshalVT(dAtA []byte) error

func (*TxAppendLog) Validate

func (t *TxAppendLog) Validate() error

Validate performs a cursory check of the transaction.

type TxComplete

type TxComplete struct {

	// Result is information about the outcome of a completed execution.
	Result *value.Result `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
	// contains filtered or unexported fields
}

TxComplete completes the execution by setting the result. Execution must be in the RUNNING state. Sender must be the peer_id specified on the Execution. TxType: TxType_COMPLETE

func (*TxComplete) CloneMessageVT

func (m *TxComplete) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TxComplete) CloneVT

func (m *TxComplete) CloneVT() *TxComplete

func (*TxComplete) EqualMessageVT

func (this *TxComplete) EqualMessageVT(thatMsg any) bool

func (*TxComplete) EqualVT

func (this *TxComplete) EqualVT(that *TxComplete) bool

func (*TxComplete) ExecuteTx

func (t *TxComplete) ExecuteTx(
	ctx context.Context,
	sender peer.ID,
	exCursor *block.Cursor,
	root *forge_execution.Execution,
) error

ExecuteTx executes the transaction against the execution instance.

func (*TxComplete) GetResult

func (x *TxComplete) GetResult() *value.Result

func (*TxComplete) GetTxType

func (t *TxComplete) GetTxType() TxType

GetTxType returns the type of transaction this is.

func (*TxComplete) MarshalJSON

func (x *TxComplete) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TxComplete to JSON.

func (*TxComplete) MarshalProtoJSON

func (x *TxComplete) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TxComplete message to JSON.

func (*TxComplete) MarshalProtoText

func (x *TxComplete) MarshalProtoText() string

func (*TxComplete) MarshalToSizedBufferVT

func (m *TxComplete) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TxComplete) MarshalToVT

func (m *TxComplete) MarshalToVT(dAtA []byte) (int, error)

func (*TxComplete) MarshalVT

func (m *TxComplete) MarshalVT() (dAtA []byte, err error)

func (*TxComplete) ProtoMessage

func (*TxComplete) ProtoMessage()

func (*TxComplete) Reset

func (x *TxComplete) Reset()

func (*TxComplete) SizeVT

func (m *TxComplete) SizeVT() (n int)

func (*TxComplete) String

func (x *TxComplete) String() string

func (*TxComplete) UnmarshalJSON

func (x *TxComplete) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TxComplete from JSON.

func (*TxComplete) UnmarshalProtoJSON

func (x *TxComplete) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TxComplete message from JSON.

func (*TxComplete) UnmarshalVT

func (m *TxComplete) UnmarshalVT(dAtA []byte) error

func (*TxComplete) Validate

func (t *TxComplete) Validate() error

Validate performs a cursory check of the transaction. Note: this should not fetch network data.

type TxSetOutputs

type TxSetOutputs struct {

	// Outputs is the set of values to set.
	Outputs []*value.Value `protobuf:"bytes,1,rep,name=outputs,proto3" json:"outputs,omitempty"`
	// ClearOld indicates to clear all old output values before setting.
	ClearOld bool `protobuf:"varint,2,opt,name=clear_old,json=clearOld,proto3" json:"clearOld,omitempty"`
	// contains filtered or unexported fields
}

TxSetOutputs updates the value of one or more execution outputs. Execution must be in the RUNNING state. Sender must be the peer_id specified on the Execution. TxType: TxType_SET_OUTPUTS

func (*TxSetOutputs) CloneMessageVT

func (m *TxSetOutputs) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TxSetOutputs) CloneVT

func (m *TxSetOutputs) CloneVT() *TxSetOutputs

func (*TxSetOutputs) EqualMessageVT

func (this *TxSetOutputs) EqualMessageVT(thatMsg any) bool

func (*TxSetOutputs) EqualVT

func (this *TxSetOutputs) EqualVT(that *TxSetOutputs) bool

func (*TxSetOutputs) ExecuteTx

func (t *TxSetOutputs) ExecuteTx(
	ctx context.Context,
	sender peer.ID,
	exCursor *block.Cursor,
	root *forge_execution.Execution,
) error

ExecuteTx executes the transaction against the execution instance.

func (*TxSetOutputs) GetClearOld

func (x *TxSetOutputs) GetClearOld() bool

func (*TxSetOutputs) GetOutputs

func (x *TxSetOutputs) GetOutputs() []*value.Value

func (*TxSetOutputs) GetTxType

func (t *TxSetOutputs) GetTxType() TxType

GetTxType returns the type of transaction this is.

func (*TxSetOutputs) MarshalJSON

func (x *TxSetOutputs) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TxSetOutputs to JSON.

func (*TxSetOutputs) MarshalProtoJSON

func (x *TxSetOutputs) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TxSetOutputs message to JSON.

func (*TxSetOutputs) MarshalProtoText

func (x *TxSetOutputs) MarshalProtoText() string

func (*TxSetOutputs) MarshalToSizedBufferVT

func (m *TxSetOutputs) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TxSetOutputs) MarshalToVT

func (m *TxSetOutputs) MarshalToVT(dAtA []byte) (int, error)

func (*TxSetOutputs) MarshalVT

func (m *TxSetOutputs) MarshalVT() (dAtA []byte, err error)

func (*TxSetOutputs) ProtoMessage

func (*TxSetOutputs) ProtoMessage()

func (*TxSetOutputs) Reset

func (x *TxSetOutputs) Reset()

func (*TxSetOutputs) SizeVT

func (m *TxSetOutputs) SizeVT() (n int)

func (*TxSetOutputs) String

func (x *TxSetOutputs) String() string

func (*TxSetOutputs) UnmarshalJSON

func (x *TxSetOutputs) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TxSetOutputs from JSON.

func (*TxSetOutputs) UnmarshalProtoJSON

func (x *TxSetOutputs) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TxSetOutputs message from JSON.

func (*TxSetOutputs) UnmarshalVT

func (m *TxSetOutputs) UnmarshalVT(dAtA []byte) error

func (*TxSetOutputs) Validate

func (t *TxSetOutputs) Validate() error

Validate performs a cursory check of the transaction. Note: this should not fetch network data.

type TxStart

type TxStart struct {

	// PeerId is the peer identifier to set as the executor.
	// Must be the same as the sender of the transaction.
	// Must match peer_id on the Execution if it's not empty.
	PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// contains filtered or unexported fields
}

TxStart starts the execution with a peer id. Execution must be in the PENDING state. TxType: TxType_START

func (*TxStart) CloneMessageVT

func (m *TxStart) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TxStart) CloneVT

func (m *TxStart) CloneVT() *TxStart

func (*TxStart) EqualMessageVT

func (this *TxStart) EqualMessageVT(thatMsg any) bool

func (*TxStart) EqualVT

func (this *TxStart) EqualVT(that *TxStart) bool

func (*TxStart) ExecuteTx

func (t *TxStart) ExecuteTx(
	ctx context.Context,
	sender peer.ID,
	exCursor *block.Cursor,
	root *forge_execution.Execution,
) error

ExecuteTx executes the transaction against the execution instance.

func (*TxStart) GetPeerId

func (x *TxStart) GetPeerId() string

func (*TxStart) GetTxType

func (t *TxStart) GetTxType() TxType

GetTxType returns the type of transaction this is.

func (*TxStart) MarshalJSON

func (x *TxStart) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TxStart to JSON.

func (*TxStart) MarshalProtoJSON

func (x *TxStart) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TxStart message to JSON.

func (*TxStart) MarshalProtoText

func (x *TxStart) MarshalProtoText() string

func (*TxStart) MarshalToSizedBufferVT

func (m *TxStart) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TxStart) MarshalToVT

func (m *TxStart) MarshalToVT(dAtA []byte) (int, error)

func (*TxStart) MarshalVT

func (m *TxStart) MarshalVT() (dAtA []byte, err error)

func (*TxStart) ParsePeerID

func (t *TxStart) ParsePeerID() (peer.ID, error)

ParsePeerID parses the peer ID field.

func (*TxStart) ProtoMessage

func (*TxStart) ProtoMessage()

func (*TxStart) Reset

func (x *TxStart) Reset()

func (*TxStart) SizeVT

func (m *TxStart) SizeVT() (n int)

func (*TxStart) String

func (x *TxStart) String() string

func (*TxStart) UnmarshalJSON

func (x *TxStart) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TxStart from JSON.

func (*TxStart) UnmarshalProtoJSON

func (x *TxStart) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TxStart message from JSON.

func (*TxStart) UnmarshalVT

func (m *TxStart) UnmarshalVT(dAtA []byte) error

func (*TxStart) Validate

func (t *TxStart) Validate() error

Validate performs a cursory check of the transaction. Note: this should not fetch network data.

type TxType

type TxType int32

TxType indicates the kind of transaction.

const (
	TxType_TxType_INVALID TxType = 0
	// TxType_START starts execution of the transaction.
	TxType_TxType_START TxType = 1
	// TxType_SET_OUTPUTS changes the value of an output.
	TxType_TxType_SET_OUTPUTS TxType = 2
	// TxType_COMPLETE sets the result of the execution.
	TxType_TxType_COMPLETE TxType = 3
	// TxType_APPEND_LOG appends log entries to the execution.
	TxType_TxType_APPEND_LOG TxType = 4
)

func (TxType) Enum

func (x TxType) Enum() *TxType

func (TxType) MarshalJSON

func (x TxType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TxType to JSON.

func (TxType) MarshalProtoJSON

func (x TxType) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TxType to JSON.

func (TxType) MarshalProtoText

func (x TxType) MarshalProtoText() string

func (TxType) MarshalText

func (x TxType) MarshalText() ([]byte, error)

MarshalText marshals the TxType to text.

func (TxType) String

func (x TxType) String() string

func (*TxType) UnmarshalJSON

func (x *TxType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TxType from JSON.

func (*TxType) UnmarshalProtoJSON

func (x *TxType) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TxType from JSON.

func (*TxType) UnmarshalText

func (x *TxType) UnmarshalText(b []byte) error

UnmarshalText unmarshals the TxType from text.

func (TxType) Validate

func (t TxType) Validate() error

Validate checks the execution tx type is in range.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL