wasm

package
v0.0.0-...-f069fcf Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

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

	ACCOUNT   = "account"
	ALLOC_MEM = "allocate"
)

Variables

This section is empty.

Functions

func EmptyImports

func EmptyImports() (*wasmer.Imports, error)

Types

type Contract

type Contract struct {
	// contract byte
	Code []byte

	// contract hash
	Hash *types.Hash
}

Contract represents the smart contract structure used in the wasm vm

type Wasm

type Wasm struct {
	// wasm instance
	Instance wasmer.Instance

	sync.RWMutex
	// contains filtered or unexported fields
}

Wasm represents the wasm vm in BitXHub

func New

func New(contractByte []byte, imports *wasmer.Imports, instances *sync.Map) (*Wasm, error)

New creates a wasm vm instance

func (*Wasm) Execute

func (w *Wasm) Execute(input []byte) ([]byte, 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