types

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteFunc

type ExecuteFunc func(*types.TransactionOrder, ExecutionContext) (*types.ServerMetadata, error)

type ExecutionContext

type ExecutionContext interface {
	predicates.TxContext
	GetData() []byte     // read data added by the GetData function
	SetData(data []byte) // add arbitrary data to the execution context
	WithExArg(func() ([]byte, error)) ExecutionContext
	ExecutionType() ExecutionType
	SetExecutionType(exeType ExecutionType)
}

ExecutionContext - provides additional context and info for tx validation and execution

type ExecutionType

type ExecutionType uint
const (
	ExecutionTypeUnconditional ExecutionType = iota // normal execution
	ExecutionTypeConditional                        // creating dummy units and placing tx "on hold"
	ExecutionTypeCommit                             // converting dummy units to normal units and executing "on hold" tx
	ExecutionTypeRollback                           // deleting dummy units?
)

transaction execution types

type FeeBalanceValidator

type FeeBalanceValidator interface {
	IsCredible(exeCtx ExecutionContext, tx *types.TransactionOrder) error
}

type FeeCalculation

type FeeCalculation interface {
	BuyGas(tema uint64) uint64
	CalculateCost(spentGas uint64) uint64
}

type FeeCreditModule

type FeeCreditModule interface {
	Module
	FeeCalculation
	FeeBalanceValidator
	FeeTxVerifier

	IsPermissionedMode() bool
	IsFeelessMode() bool
	FeeCreditRecordUnitType() uint32
}

type FeeTxVerifier

type FeeTxVerifier interface {
	IsFeeCreditTx(tx *types.TransactionOrder) bool
}

type GenericExecuteFunc

type GenericExecuteFunc[A, P any] func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) (*types.ServerMetadata, error)

type GenericTargetUnitsFunc

type GenericTargetUnitsFunc[A, P any] func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) ([]types.UnitID, error)

type GenericValidateFunc

type GenericValidateFunc[A, P any] func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) error

type Module

type Module interface {
	TxHandlers() map[uint16]TxExecutor
}

type StateInfo

type StateInfo interface {
	GetUnit(id types.UnitID, committed bool) (state.Unit, error)
	CommittedUC() *types.UnicityCertificate
	CurrentRound() uint64
}

type TxExecutionContext

type TxExecutionContext struct {
	// contains filtered or unexported fields
}

TxExecutionContext - implementation of ExecutionContext interface for generic tx handler

func NewExecutionContext

func NewExecutionContext(txSys StateInfo, f FeeCalculation, tb types.RootTrustBase, maxCost uint64) *TxExecutionContext

func (*TxExecutionContext) CalculateCost

func (ec *TxExecutionContext) CalculateCost() uint64

func (*TxExecutionContext) CommittedUC

func (ec *TxExecutionContext) CommittedUC() *types.UnicityCertificate

func (*TxExecutionContext) CurrentRound

func (ec *TxExecutionContext) CurrentRound() uint64

func (*TxExecutionContext) ExecutionType

func (ec *TxExecutionContext) ExecutionType() ExecutionType

func (*TxExecutionContext) ExtraArgument

func (ec *TxExecutionContext) ExtraArgument() ([]byte, error)

ExtraArgument calls the function set using WithExArg method.

This can be used to provide "extra argument" for the predicate, currently used ie by the P2PKH predicate to receive the signature bytes it should verify.

func (*TxExecutionContext) GasAvailable

func (ec *TxExecutionContext) GasAvailable() uint64

func (*TxExecutionContext) GetData

func (ec *TxExecutionContext) GetData() []byte

func (*TxExecutionContext) GetUnit

func (ec *TxExecutionContext) GetUnit(id types.UnitID, committed bool) (state.Unit, error)

func (*TxExecutionContext) SetData

func (ec *TxExecutionContext) SetData(data []byte)

func (*TxExecutionContext) SetExecutionType

func (ec *TxExecutionContext) SetExecutionType(exeType ExecutionType)

func (*TxExecutionContext) SpendGas

func (ec *TxExecutionContext) SpendGas(gas uint64) error

func (*TxExecutionContext) TrustBase

func (ec *TxExecutionContext) TrustBase(epoch uint64) (types.RootTrustBase, error)

func (*TxExecutionContext) WithExArg

func (ec *TxExecutionContext) WithExArg(f func() ([]byte, error)) ExecutionContext

WithExArg sets the "extra argument" callback which is used by the ExtraArgument method.

type TxExecutor

type TxExecutor interface {
	UnmarshalTx(txo *types.TransactionOrder, ctx ExecutionContext) (any, any, []types.UnitID, error)
	ValidateTx(tx *types.TransactionOrder, attributes any, authProof any, exeCtx ExecutionContext) error
	ExecuteTxWithAttr(tx *types.TransactionOrder, attributes any, authProof any, exeCtx ExecutionContext) (*types.ServerMetadata, error)
	ExecuteTx(tx *types.TransactionOrder, exeCtx ExecutionContext) (*types.ServerMetadata, error)
}

type TxExecutors

type TxExecutors map[uint16]TxExecutor

func (TxExecutors) Add

func (h TxExecutors) Add(src TxExecutors) error

func (TxExecutors) Execute

func (h TxExecutors) Execute(txo *types.TransactionOrder, exeCtx ExecutionContext) (*types.ServerMetadata, error)

func (TxExecutors) ExecuteWithAttr

func (h TxExecutors) ExecuteWithAttr(txo *types.TransactionOrder, attr any, authProof any, exeCtx ExecutionContext) (*types.ServerMetadata, error)

func (TxExecutors) UnmarshalTx

func (h TxExecutors) UnmarshalTx(tx *types.TransactionOrder, exeCtx ExecutionContext) (any, any, []types.UnitID, error)

func (TxExecutors) Validate

func (h TxExecutors) Validate(txo *types.TransactionOrder, attr any, authProof any, exeCtx ExecutionContext) error

func (TxExecutors) ValidateAndExecute

func (h TxExecutors) ValidateAndExecute(txo *types.TransactionOrder, exeCtx ExecutionContext) (*types.ServerMetadata, error)

type TxHandler

type TxHandler[A any, P any] struct {
	Execute     func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) (*types.ServerMetadata, error)
	Validate    func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) error
	TargetUnits func(tx *types.TransactionOrder, attributes *A, authProof *P, exeCtx ExecutionContext) ([]types.UnitID, error)
}

func NewTxHandler

func NewTxHandler[A, P any](v GenericValidateFunc[A, P], e GenericExecuteFunc[A, P], opts ...TxHandlerOption[A, P]) *TxHandler[A, P]

func (*TxHandler[A, P]) ExecuteTx

func (t *TxHandler[A, P]) ExecuteTx(txo *types.TransactionOrder, exeCtx ExecutionContext) (*types.ServerMetadata, error)

func (*TxHandler[A, P]) ExecuteTxWithAttr

func (t *TxHandler[A, P]) ExecuteTxWithAttr(txo *types.TransactionOrder, attr any, authProof any, exeCtx ExecutionContext) (*types.ServerMetadata, error)

func (*TxHandler[A, P]) UnmarshalTx

func (t *TxHandler[A, P]) UnmarshalTx(txo *types.TransactionOrder, exeCtx ExecutionContext) (any, any, []types.UnitID, error)

func (*TxHandler[A, P]) ValidateTx

func (t *TxHandler[A, P]) ValidateTx(txo *types.TransactionOrder, attr any, authProof any, exeCtx ExecutionContext) error

type TxHandlerOption

type TxHandlerOption[A any, P any] func(*TxHandler[A, P])

func WithTargetUnitsFn

func WithTargetUnitsFn[A, P any](u GenericTargetUnitsFunc[A, P]) TxHandlerOption[A, P]

type ValidateFunc

type ValidateFunc func(*types.TransactionOrder, ExecutionContext) error

Jump to

Keyboard shortcuts

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