Documentation ¶
Index ¶
- Variables
- func NewStateSummary(rootHash []byte, summary []byte) stateSummary
- type ExecuteFunc
- type FeeCreditBalanceValidator
- type GenericExecuteFunc
- type GenericTxSystem
- func (m *GenericTxSystem) BeginBlock(blockNr uint64) error
- func (m *GenericTxSystem) Commit(uc *types.UnicityCertificate) error
- func (m *GenericTxSystem) CommittedUC() *types.UnicityCertificate
- func (m *GenericTxSystem) EndBlock() (StateSummary, error)
- func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (sm *types.ServerMetadata, rErr error)
- func (m *GenericTxSystem) Revert()
- func (m *GenericTxSystem) SerializeState(writer io.Writer, committed bool) error
- func (m *GenericTxSystem) State() StateReader
- func (m *GenericTxSystem) StateSummary() (StateSummary, error)
- type Module
- type Observability
- type Option
- type Options
- type StateReader
- type StateSummary
- type TransactionSystem
- type TxExecutors
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 NewStateSummary ¶
Types ¶
type ExecuteFunc ¶
type ExecuteFunc func(tx *types.TransactionOrder, currentBlockNr uint64) (*types.ServerMetadata, error)
type FeeCreditBalanceValidator ¶
type FeeCreditBalanceValidator func(tx *types.TransactionOrder) error
type GenericExecuteFunc ¶
type GenericExecuteFunc[T any] func(tx *types.TransactionOrder, attributes *T, currentBlockNr uint64) (*types.ServerMetadata, error)
func (GenericExecuteFunc[T]) ExecuteFunc ¶
func (g GenericExecuteFunc[T]) ExecuteFunc() ExecuteFunc
type GenericTxSystem ¶
type GenericTxSystem struct {
// contains filtered or unexported fields
}
func NewGenericTxSystem ¶
func NewGenericTxSystem(systemID types.SystemID, feeChecker FeeCreditBalanceValidator, modules []Module, observe Observability, opts ...Option) (*GenericTxSystem, error)
func (*GenericTxSystem) BeginBlock ¶
func (m *GenericTxSystem) BeginBlock(blockNr uint64) error
func (*GenericTxSystem) Commit ¶
func (m *GenericTxSystem) Commit(uc *types.UnicityCertificate) error
func (*GenericTxSystem) CommittedUC ¶
func (m *GenericTxSystem) CommittedUC() *types.UnicityCertificate
func (*GenericTxSystem) EndBlock ¶
func (m *GenericTxSystem) EndBlock() (StateSummary, error)
func (*GenericTxSystem) Execute ¶
func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (sm *types.ServerMetadata, rErr error)
func (*GenericTxSystem) Revert ¶
func (m *GenericTxSystem) Revert()
func (*GenericTxSystem) SerializeState ¶
func (m *GenericTxSystem) SerializeState(writer io.Writer, committed bool) error
func (*GenericTxSystem) State ¶
func (m *GenericTxSystem) State() StateReader
func (*GenericTxSystem) StateSummary ¶
func (m *GenericTxSystem) StateSummary() (StateSummary, error)
type Module ¶
type Module interface {
TxExecutors() map[string]ExecuteFunc
}
type Observability ¶
type Option ¶
type Option func(*Options)
func WithBeginBlockFunctions ¶
func WithEndBlockFunctions ¶
func WithHashAlgorithm ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() *Options
type StateReader ¶ added in v0.4.0
type StateReader interface { GetUnit(id types.UnitID, committed bool) (*state.Unit, error) CreateUnitStateProof(id types.UnitID, logIndex int) (*types.UnitStateProof, error) CreateIndex(state.KeyExtractor[string]) (state.Index[string], error) // Serialize writes the serialized state to the given writer. Serialize(writer io.Writer, committed bool) error }
type StateSummary ¶
type StateSummary interface { // Root returns the root hash of the TransactionSystem. Root() []byte // Summary returns the summary value of the state. Summary() []byte }
StateSummary represents the root hash and summary value of the transaction system.
type TransactionSystem ¶
type TransactionSystem interface { // StateSummary returns the summary of the current state of the transaction system or an ErrStateContainsUncommittedChanges if // current state contains uncommitted changes. StateSummary() (StateSummary, 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() (StateSummary, 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(uc *types.UnicityCertificate) error // CommittedUC returns the unicity certificate of the latest commit. CommittedUC() *types.UnicityCertificate // State returns clone of transaction system state State() StateReader }
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 TxExecutors ¶
type TxExecutors map[string]ExecuteFunc
func (TxExecutors) Add ¶
func (e TxExecutors) Add(src TxExecutors) error
func (TxExecutors) Execute ¶
func (e TxExecutors) Execute(txo *types.TransactionOrder, currentBlockNr uint64) (*types.ServerMetadata, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.