wasm

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTEXT_ARGMAP    = "argmap"
	CONTEXT_INTERFACE = "interface"
	ERROR             = "error"

	ASSEMBLYSCRIPT_ENTRY = "_start"
)

Variables

This section is empty.

Functions

func NewStore

func NewStore() *wasmtime.Store

Types

type Contract

type Contract struct {
	// contract byte
	Code []byte `json:"code"`

	// contract hash
	Hash *types.Hash `json:"hash"`
}

Contract represents the smart contract structure used in the wasm vm

type Wasm

type Wasm struct {
	// wasm instance
	Instance *wasmtime.Instance
	Store    *wasmtime.Store

	sync.RWMutex
	// contains filtered or unexported fields
}

Wasm represents the wasm vm in BitXHub

func New

func New(code []byte, context map[string]interface{}, libs []*wasmlib.ImportLib) (*Wasm, error)

New creates a wasm vm instance

func NewWithStore

func NewWithStore(code []byte, context map[string]interface{}, libs []*wasmlib.ImportLib, store *wasmtime.Store) (*Wasm, error)

func (*Wasm) Execute

func (w *Wasm) Execute(input []byte, wasmGasLimit uint64) (ret []byte, gasUsed uint64, err error)

func (*Wasm) FreeBytes

func (w *Wasm) FreeBytes(inputPointer interface{}, b []byte) error

FreeBytes free the bytes type arg for wasm

func (*Wasm) FreeString

func (w *Wasm) FreeString(inputPointer interface{}, str string) error

FreeString free the string type arg for wasm

func (*Wasm) GetContext

func (w *Wasm) GetContext(key string) interface{}

func (*Wasm) SetBytes

func (w *Wasm) SetBytes(b []byte) (int32, error)

SetBytes set bytes type arg for wasm

func (*Wasm) SetContext

func (w *Wasm) SetContext(key string, value interface{})

func (*Wasm) SetString

func (w *Wasm) SetString(str string) (int32, error)

SetString set the string type arg for wasm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL