Documentation ¶
Index ¶
- Variables
- func ValidateGenericTransaction(ctx *TxValidationContext) error
- type ExecuteFunc
- type GenericExecuteFunc
- type GenericTransactionValidator
- type GenericTxSystem
- func (m *GenericTxSystem) BeginBlock(blockNr uint64) error
- func (m *GenericTxSystem) Commit() error
- func (m *GenericTxSystem) CurrentBlockNumber() uint64
- func (m *GenericTxSystem) EndBlock() (State, error)
- func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (sm *types.ServerMetadata, err error)
- func (m *GenericTxSystem) GetState() *state.State
- func (m *GenericTxSystem) Revert()
- func (m *GenericTxSystem) StateSummary() (State, error)
- type Module
- type Option
- type Options
- type State
- type StateSummary
- type SystemDescriptions
- type TransactionSystem
- type TxExecutor
- type TxExecutors
- type TxValidationContext
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTransactionExpired = errors.New("transaction timeout must be greater than current block number") ErrInvalidSystemIdentifier = errors.New("error invalid system identifier") )
View Source
var ErrStateContainsUncommittedChanges = errors.New("state contains uncommitted changes")
Functions ¶
func ValidateGenericTransaction ¶
func ValidateGenericTransaction(ctx *TxValidationContext) error
Types ¶
type ExecuteFunc ¶ added in v0.2.0
type ExecuteFunc func(tx *types.TransactionOrder, currentBlockNr uint64) (*types.ServerMetadata, error)
func (ExecuteFunc) ExecuteFunc ¶ added in v0.2.0
func (e ExecuteFunc) ExecuteFunc() ExecuteFunc
type GenericExecuteFunc ¶ added in v0.2.0
type GenericExecuteFunc[T any] func(tx *types.TransactionOrder, attributes *T, currentBlockNr uint64) (*types.ServerMetadata, error)
func (GenericExecuteFunc[T]) ExecuteFunc ¶ added in v0.2.0
func (g GenericExecuteFunc[T]) ExecuteFunc() ExecuteFunc
type GenericTransactionValidator ¶ added in v0.2.0
type GenericTransactionValidator func(ctx *TxValidationContext) error
type GenericTxSystem ¶ added in v0.2.0
type GenericTxSystem struct {
// contains filtered or unexported fields
}
func NewGenericTxSystem ¶ added in v0.2.0
func NewGenericTxSystem(modules []Module, opts ...Option) (*GenericTxSystem, error)
func (*GenericTxSystem) BeginBlock ¶ added in v0.2.0
func (m *GenericTxSystem) BeginBlock(blockNr uint64) error
func (*GenericTxSystem) Commit ¶ added in v0.2.0
func (m *GenericTxSystem) Commit() error
func (*GenericTxSystem) CurrentBlockNumber ¶ added in v0.2.0
func (m *GenericTxSystem) CurrentBlockNumber() uint64
func (*GenericTxSystem) EndBlock ¶ added in v0.2.0
func (m *GenericTxSystem) EndBlock() (State, error)
func (*GenericTxSystem) Execute ¶ added in v0.2.0
func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (sm *types.ServerMetadata, err error)
func (*GenericTxSystem) GetState ¶ added in v0.2.0
func (m *GenericTxSystem) GetState() *state.State
func (*GenericTxSystem) Revert ¶ added in v0.2.0
func (m *GenericTxSystem) Revert()
func (*GenericTxSystem) StateSummary ¶ added in v0.2.0
func (m *GenericTxSystem) StateSummary() (State, error)
type Module ¶ added in v0.2.0
type Module interface { TxExecutors() map[string]TxExecutor GenericTransactionValidator() GenericTransactionValidator }
type Option ¶ added in v0.2.0
type Option func(*Options)
func WithBeginBlockFunctions ¶ added in v0.2.0
func WithEndBlockFunctions ¶ added in v0.2.0
func WithHashAlgorithm ¶ added in v0.2.0
func WithSystemIdentifier ¶ added in v0.2.0
type Options ¶ added in v0.2.0
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶ added in v0.2.0
func DefaultOptions() *Options
type State ¶
type State interface { // Root returns the root hash of the TransactionSystem. Root() []byte // Summary returns the summary value of the state. Summary() []byte }
State represents the root hash and summary value of the transaction system.
type StateSummary ¶
type StateSummary struct {
// contains filtered or unexported fields
}
StateSummary is a default implementation of State interface.
func NewStateSummary ¶
func NewStateSummary(rootHash []byte, summary []byte) StateSummary
func (StateSummary) Root ¶
func (s StateSummary) Root() []byte
func (StateSummary) Summary ¶
func (s StateSummary) Summary() []byte
type SystemDescriptions ¶ added in v0.2.0
type SystemDescriptions map[string]*genesis.SystemDescriptionRecord
SystemDescriptions is map of system description records indexed by System Identifiers
type TransactionSystem ¶
type TransactionSystem interface { // StateSummary returns the current state of the transaction system or an ErrStateContainsUncommittedChanges if // current state contains uncommitted changes. StateSummary() (State, error) // BeginBlock signals the start of a new block and is invoked before any Execute method calls. BeginBlock(uint64) error // Execute method executes the transaction order. An error must be returned if the transaction order execution // was not successful. Execute(order *types.TransactionOrder) (*types.ServerMetadata, error) // EndBlock signals the end of the block and is called after all transactions have been delivered to the // transaction system. EndBlock() (State, error) // Revert signals the unsuccessful consensus round. When called the transaction system must revert all the changes // made during the BeginBlock, EndBlock, and Execute method calls. Revert() // Commit signals the successful consensus round. Called after the block was approved by the root chain. When called // the transaction system must commit all the changes made during the BeginBlock, // EndBlock, and Execute method calls. Commit() error }
TransactionSystem is a set of rules and logic for defining units and performing transactions with them. The following sequence of methods is executed for each block: BeginBlock, Execute (called once for each transaction in the block), EndBlock, and Commit (consensus round was successful) or Revert (consensus round was unsuccessful).
type TxExecutor ¶ added in v0.2.0
type TxExecutor interface {
ExecuteFunc() ExecuteFunc
}
type TxExecutors ¶ added in v0.2.0
type TxExecutors map[string]TxExecutor
func (TxExecutors) Execute ¶ added in v0.2.0
func (e TxExecutors) Execute(g *types.TransactionOrder, currentBlockNr uint64) (*types.ServerMetadata, error)
type TxValidationContext ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.