vm

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseVM

type BaseVM interface {
	// Type return the vm type.
	Type() string
	// Close close vm.
	Close()
}

BaseVM is the part interface of VM that will be called in both master and worker

type MasterVM

type MasterVM interface {
	// BeforeDeploy will call before deploy contract.
	BeforeDeploy() error
	// DeployContract deploy contract.
	DeployContract() error
	// BeforeGet will call before get context.
	BeforeGet() error
	// GetContext generate context for execute tx in vm.
	GetContext() ([]byte, error)
	// Statistic statistic remote execute info.
	Statistic(from, to *fcom.ChainInfo) (*fcom.RemoteStatistic, error)
	// LogStatus records blockheight and time
	LogStatus() (*fcom.ChainInfo, error)
}

MasterVM is the part interface of VM that will be called in master

type Type

type Type string

Type is the ext name of script file

const (
	// LUA vm type of lua.
	LUA Type = "lua"
)

type VM

type VM interface {
	BaseVM
	MasterVM
	WorkerVM
}

VM is the integrated interface of Virtual Machine running script

func NewVM

func NewVM(vmType string, configBase base.ConfigBase) (VM, error)

NewVM creates a VM according to type and config

type WorkerVM

type WorkerVM interface {
	// BeforeSet will call before set context.
	BeforeSet() error
	// SetContext set context for execute tx in vm, the ctx is generated by GetContext.
	SetContext(ctx []byte) error
	// BeforeRun will call once before run.
	BeforeRun() error
	// Run create and send tx to client.
	Run(ctx fcom.TxContext) (*fcom.Result, error)
	// Verify check the relative time of transaction
	Verify(*fcom.Result, ...fcom.Option) *fcom.Result
	// AfterRun will call once after run.
	AfterRun() error
}

WorkerVM is the part interface of VM that will be called in worker

Directories

Path Synopsis
lua

Jump to

Keyboard shortcuts

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