Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ABTypesFactory ¶
type ABTypesFactory struct{}
AB "common types", ie not tx system specific stuff
type Encoder ¶
type Encoder interface { Encode(obj any, ver uint32, getHandle func(obj any) uint64) ([]byte, error) TxAttributes(txo *types.TransactionOrder, ver uint32) ([]byte, error) UnitData(unit *state.Unit, ver uint32) ([]byte, error) }
translates AB types to WASM consumable representation
type EvalEnvironment ¶
type EvalResult ¶
type EvalResult int
const ( EvalResultTrue EvalResult = 1 EvalResultFalse EvalResult = 2 EvalResultError EvalResult = 3 )
func PredicateEvalResult ¶
func PredicateEvalResult(code uint64) (EvalResult, uint64)
type Observability ¶
type Option ¶
type Option func(*Options)
func WithRuntimeConfig ¶
func WithRuntimeConfig(cfg wazero.RuntimeConfig) Option
func WithStorage ¶
func WithStorage(db keyvaluedb.KeyValueDB) Option
type WasmVM ¶
type WasmVM struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, enc Encoder, engines predicates.PredicateExecutor, observe Observability, opts ...Option) (*WasmVM, error)
New - creates new wazero based wasm vm
func (*WasmVM) Exec ¶
func (vm *WasmVM) Exec(ctx context.Context, predicate, args []byte, conf wasm.PredicateParams, sigBytesFn func() ([]byte, error), env EvalEnvironment) (uint64, error)
Exec loads the WASM module passed in as "predicate" argument and calls the "conf.Entrypoint" function in it.
- The entrypoint function signature must be "no parameters and single i64 return value" where zero means "true" and non-zero is "false" (ie the returned number is error code);
Source Files ¶
Click to show internal directories.
Click to hide internal directories.