Documentation ¶
Index ¶
- type AppManager
- func (a AppManager[T]) DeliverBlock(ctx context.Context, block *appmanager.BlockRequest[T]) (*appmanager.BlockResponse, corestore.WriterMap, error)
- func (a AppManager[T]) ExportGenesis(ctx context.Context, version uint64) ([]byte, error)
- func (a AppManager[T]) InitGenesis(ctx context.Context, blockRequest *appmanager.BlockRequest[T], ...) (*appmanager.BlockResponse, corestore.WriterMap, error)
- func (a AppManager[T]) Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error)
- func (a AppManager[T]) QueryWithState(ctx context.Context, state corestore.ReaderMap, request transaction.Msg) (transaction.Msg, error)
- func (a AppManager[T]) Simulate(ctx context.Context, tx T) (appmanager.TxResult, corestore.WriterMap, error)
- func (a AppManager[T]) ValidateTx(ctx context.Context, tx T) (appmanager.TxResult, error)
- type Builder
- type Config
- type ExportGenesis
- type InitGenesis
- type StateTransitionFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppManager ¶
type AppManager[T transaction.Tx] struct { // contains filtered or unexported fields }
AppManager is a coordinator for all things related to an application TODO: add exportGenesis function
func (AppManager[T]) DeliverBlock ¶
func (a AppManager[T]) DeliverBlock( ctx context.Context, block *appmanager.BlockRequest[T], ) (*appmanager.BlockResponse, corestore.WriterMap, error)
func (AppManager[T]) ExportGenesis ¶
ExportGenesis exports the genesis state of the application.
func (AppManager[T]) InitGenesis ¶
func (a AppManager[T]) InitGenesis( ctx context.Context, blockRequest *appmanager.BlockRequest[T], initGenesisJSON []byte, txDecoder transaction.Codec[T], ) (*appmanager.BlockResponse, corestore.WriterMap, error)
func (AppManager[T]) Query ¶
func (a AppManager[T]) Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error)
Query queries the application at the provided version. CONTRACT: Version must always be provided, if 0, get latest
func (AppManager[T]) QueryWithState ¶
func (a AppManager[T]) QueryWithState( ctx context.Context, state corestore.ReaderMap, request transaction.Msg, ) (transaction.Msg, error)
QueryWithState executes a query with the provided state. This allows to process a query independently of the db state. For example, it can be used to process a query with temporary and uncommitted state
func (AppManager[T]) Simulate ¶
func (a AppManager[T]) Simulate(ctx context.Context, tx T) (appmanager.TxResult, corestore.WriterMap, error)
Simulate runs validation and execution flow of a Tx.
func (AppManager[T]) ValidateTx ¶
func (a AppManager[T]) ValidateTx(ctx context.Context, tx T) (appmanager.TxResult, error)
ValidateTx will validate the tx against the latest storage state. This means that only the stateful validation will be run, not the execution portion of the tx. If full execution is needed, Simulate must be used.
type Builder ¶
type Builder[T transaction.Tx] struct { STF StateTransitionFunction[T] // The state transition function for processing transactions. DB store.Store // The database for storing application data. // Gas limits for validating, querying, and simulating transactions. ValidateTxGasLimit uint64 QueryGasLimit uint64 SimulationGasLimit uint64 // InitGenesis is a function that initializes the application state from a genesis file. // It takes a context, a source reader for the genesis file, and a transaction handler function. InitGenesis InitGenesis // ExportGenesis is a function that exports the application state to a genesis file. // It takes a context and a version number for the genesis file. ExportGenesis ExportGenesis }
Builder is a struct that represents the application builder for managing transactions. It contains various fields and methods for initializing the application and handling transactions.
func (Builder[T]) Build ¶
func (b Builder[T]) Build() (*AppManager[T], error)
Build creates a new instance of AppManager with the provided configuration and returns it. It initializes the AppManager with the given database, export state, import state, initGenesis function, and state transition function.
type Config ¶
type Config struct { ValidateTxGasLimit uint64 `mapstructure:"validate-tx-gas-limit"` // TODO: check how this works on app mempool QueryGasLimit uint64 `mapstructure:"query-gas-limit"` SimulationGasLimit uint64 `mapstructure:"simulation-gas-limit"` }
Config represents the configuration options for the app manager. TODO: implement comments for toml
type ExportGenesis ¶
exportGenesis is a function type that represents the export of the genesis state.
type InitGenesis ¶
type InitGenesis func(ctx context.Context, src io.Reader, txHandler func(json.RawMessage) error) error
InitGenesis is a function type that represents the initialization of the genesis state.
type StateTransitionFunction ¶
type StateTransitionFunction[T transaction.Tx] interface { // DeliverBlock executes a block of transactions. DeliverBlock( ctx context.Context, block *appmanager.BlockRequest[T], state store.ReaderMap, ) (blockResult *appmanager.BlockResponse, newState store.WriterMap, err error) // ValidateTx validates a transaction. ValidateTx( ctx context.Context, state store.ReaderMap, gasLimit uint64, tx T, ) appmanager.TxResult // Simulate executes a transaction in simulation mode. Simulate( ctx context.Context, state store.ReaderMap, gasLimit uint64, tx T, ) (appmanager.TxResult, store.WriterMap) // Query executes a query on the application. Query( ctx context.Context, state store.ReaderMap, gasLimit uint64, req transaction.Msg, ) (transaction.Msg, error) // TODO: remove RunWithCtx( ctx context.Context, state store.ReaderMap, closure func(ctx context.Context) error, ) (store.WriterMap, error) }
StateTransitionFunction is an interface for processing transactions and blocks.