Documentation
¶
Index ¶
- Variables
- type Config
- type Context
- type DefaultImportsAsyncCall
- type DefaultImportsChainOperation
- type DefaultImportsKVStore
- type DefaultImportsMQTT
- type DefaultImportsMetrics
- type DefaultImportsResource
- type DefaultImportsSQL
- type DefaultImportsSystem
- type Exports
- type Function
- type ImportsAsyncCall
- type ImportsChainOperation
- type ImportsHandler
- type ImportsKVStore
- type ImportsMQTT
- type ImportsMetrics
- type ImportsResource
- type ImportsSQL
- type ImportsSystem
- type Instance
- type Module
- type VM
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultImportsHandler = struct { ImportsSystem ImportsResource ImportsKVStore ImportsSQL ImportsChainOperation ImportsMQTT ImportsMetrics ImportsAsyncCall }{ ImportsSystem: &DefaultImportsSystem{}, ImportsResource: &DefaultImportsResource{}, ImportsKVStore: &DefaultImportsKVStore{}, ImportsSQL: &DefaultImportsSQL{}, ImportsChainOperation: &DefaultImportsChainOperation{}, ImportsMQTT: &DefaultImportsMQTT{}, ImportsMetrics: &DefaultImportsMetrics{}, ImportsAsyncCall: &DefaultImportsAsyncCall{}, }
View Source
var ErrNotImplements = errors.New("not implements")
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
Name() string
GetImports() ImportsHandler
SetImports(ImportsHandler)
GetExports() Exports
GetInstance() Instance
SetInstance(Instance)
}
type DefaultImportsAsyncCall ¶
type DefaultImportsAsyncCall struct{}
func (*DefaultImportsAsyncCall) AsyncAPICall ¶
func (*DefaultImportsAsyncCall) AsyncAPICall(req []byte) ([]byte, error)
type DefaultImportsChainOperation ¶
type DefaultImportsChainOperation struct{}
func (*DefaultImportsChainOperation) CallContract ¶
func (*DefaultImportsChainOperation) CallContract(chainID int32, data []byte) ([]byte, error)
func (*DefaultImportsChainOperation) SendTX ¶
func (*DefaultImportsChainOperation) SendTX(chainID int32, data []byte) (string, error)
func (*DefaultImportsChainOperation) SendTXWithOperator ¶
func (*DefaultImportsChainOperation) SendTXWithOperator(chainID int32, data []byte) (string, error)
type DefaultImportsKVStore ¶
type DefaultImportsKVStore struct{}
type DefaultImportsMQTT ¶
type DefaultImportsMQTT struct{}
type DefaultImportsMetrics ¶
type DefaultImportsMetrics struct{}
func (*DefaultImportsMetrics) SubmitMetrics ¶
func (*DefaultImportsMetrics) SubmitMetrics(data []byte) error
type DefaultImportsResource ¶
type DefaultImportsResource struct{}
func (*DefaultImportsResource) GetResourceData ¶
func (v *DefaultImportsResource) GetResourceData(uint32) ([]byte, bool)
func (*DefaultImportsResource) SetResourceData ¶
func (v *DefaultImportsResource) SetResourceData(uint32, []byte) error
type DefaultImportsSQL ¶
type DefaultImportsSQL struct{}
func (*DefaultImportsSQL) ExecSQL ¶
func (*DefaultImportsSQL) ExecSQL(string) error
type DefaultImportsSystem ¶
type DefaultImportsSystem struct{}
func (*DefaultImportsSystem) Log ¶
func (l *DefaultImportsSystem) Log(level consts.LogLevel, msg string)
func (*DefaultImportsSystem) LogInternal ¶
func (l *DefaultImportsSystem) LogInternal(level consts.LogLevel, msg string)
type ImportsAsyncCall ¶
type ImportsChainOperation ¶
type ImportsChainOperation interface {
// SendTX send tx by chain id and data, returns tx hash and error
SendTX(chainID int32, data []byte) (string, error)
// SendTXWithOperator
SendTXWithOperator(chainID int32, data []byte) (string, error)
// CallContract call contract by chain id and data, returns call result
CallContract(chainID int32, data []byte) ([]byte, error)
}
type ImportsHandler ¶
type ImportsHandler interface {
ImportsSystem
ImportsResource
ImportsKVStore
ImportsSQL
ImportsChainOperation
ImportsMQTT
ImportsMetrics
ImportsAsyncCall
}
type ImportsKVStore ¶
type ImportsMQTT ¶
type ImportsMetrics ¶
type ImportsResource ¶
type ImportsSQL ¶
type ImportsSystem ¶
type Instance ¶
type Instance interface {
// RegisterImports
RegisterImports(name string) error
// Start starts wasm instance
Start() error
// Stop stops wasm instance
Stop()
// GetModule get current wasm module
GetModule() Module
// GetExportsFunc returns the exported func of the wasm instance by name
GetExportsFunc(name string) (Function, error)
// GetExportsMem returns the exported memory of the wasm instance
GetExportsMem(name string) ([]byte, error)
// GetByte returns the wasm byte from the specified addr
GetByte(addr uint64) (byte, error)
// PutByte set a wasm byte to specified addr
PutByte(addr uint64, v byte) error
// GetUint32 returns the u32 value from the specified addr
GetUint32(addr uint64) (uint32, error)
// PutUint32 sets u32 value to the specified addr
PutUint32(addr uint64, v uint32) error
// GetMemory returns wasm memory
GetMemory(addr uint64, size uint64) ([]byte, error)
// PutMemory
PutMemory(addr uint64, size uint64, data []byte) error
// Malloc allocates size of memory from wasm default memory
Malloc(size int32) (uint64, error)
// GetUserdata get user-defined data
GetUserdata() any
// SetUserdata set user-define data into wasm instance
SetUserdata(any)
// Lock gets the exclusive ownership of the wasm instance and sets userdata
Lock(any)
// Unlock releases the exclusive ownership of the wasm instance and unref userdata
Unlock()
// Acquire increases the refer count of wasm instance
Acquire() bool
// Release decreases the refer count of wasm instance
Release()
HandleError(error)
}
Instance defines the wasm instance
type Module ¶
type Module interface {
// Init was invoked when creating a wasm module
Init()
// NewInstance instantiates a wasm vm instance
NewInstance() Instance
// GetABINameList returns the abi name list exported from wasm module
GetABINameList() []string
}
Module defines interface of the wasm module
type VM ¶
type VM interface {
// Name the name of the wasm vm
Name() string
// Init was invoked when creating a new wasm vm
Init()
// NewModule compile user code into a wasm module
NewModule(code []byte) (Module, error)
// Close to prevent from memory leaking
Close() error
}
VM defines interface of the wasm virtual machine(engine)
Click to show internal directories.
Click to hide internal directories.