xvm

package
v0.0.0-...-35ce171 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCap = 10
View Source
const OptLevel = 0

Variables

View Source
var BuiltinResolver = exec.MapResolver(map[string]interface{}{
	"env._wxvm_hash":   wxvmHash,
	"env._wxvm_encode": wxvmEncode,
	"env._wxvm_decode": wxvmDecode,
})

BuiltinResolver export

View Source
var MaxLimits = Limits{
	Cpu: maxResourceLimit,
}

MaxLimits describes the maximum limit of resources

Functions

func NewContextServiceResolver

func NewContextServiceResolver(service *ContextService) exec.Resolver

Types

type CodeManager

type CodeManager struct {
	// contains filtered or unexported fields
}

func NewCodeManager

func NewCodeManager(chainId string, basedir string, log protocol.Logger) *CodeManager

func (*CodeManager) CompileCode

func (c *CodeManager) CompileCode(buf []byte, outputPath string) error

func (*CodeManager) GetExecCode

func (c *CodeManager) GetExecCode(chainId string, contract *commonPb.Contract,
	byteCode []byte, contextService *ContextService) (exec.Code, error)

func (*CodeManager) MakeExecCode

func (c *CodeManager) MakeExecCode(libpath string, contextService *ContextService) (exec.Code, error)

func (*CodeManager) RemoveCode

func (c *CodeManager) RemoveCode(name string)

type Context

type Context struct {
	ID             int64
	Parameters     map[string][]byte
	TxSimContext   protocol.TxSimContext
	ContractId     *commonPb.Contract
	ContractResult *commonPb.ContractResult

	ContractEvent []*commonPb.ContractEvent
	// contains filtered or unexported fields
}

type ContextService

type ContextService struct {
	// contains filtered or unexported fields
}

func NewContextService

func NewContextService(chainId string, log protocol.Logger) *ContextService

NewContextService build a ContextService

func (*ContextService) CallContract

func (c *ContextService) CallContract(ctxId int64) int32

CallContract implements Syscall interface

func (*ContextService) Context

func (c *ContextService) Context(id int64) (*Context, bool)

func (*ContextService) DeleteState

func (c *ContextService) DeleteState(ctxId int64) int32

DeleteState implements Syscall interface

func (*ContextService) DestroyContext

func (c *ContextService) DestroyContext(ctx *Context)

func (*ContextService) EmitEvent

func (c *ContextService) EmitEvent(ctxId int64) int32

func (*ContextService) ErrorResult

func (c *ContextService) ErrorResult(ctxId int64) int32

func (*ContextService) GetCallArgs

func (c *ContextService) GetCallArgs(ctxId int64) int32

GetCallArgs implements Syscall interface

func (*ContextService) GetState

func (c *ContextService) GetState(ctxId int64) int32

GetState implements Syscall interface

func (*ContextService) LogMessage

func (c *ContextService) LogMessage(ctxId int64) int32

LogMessage handle log entry from contract

func (*ContextService) MakeContext

func (c *ContextService) MakeContext(contract *commonPb.Contract, txSimContext protocol.TxSimContext,
	contractResult *commonPb.ContractResult, parameters map[string][]byte) *Context

func (*ContextService) NewIterator

func (c *ContextService) NewIterator(ctxId int64) int32

NewIterator implements Syscall interface

func (*ContextService) PutState

func (c *ContextService) PutState(ctxId int64) int32

PutState implements Syscall interface

func (*ContextService) SetOutput

func (c *ContextService) SetOutput(ctxId int64) int32

SetOutput implements Syscall interface

func (*ContextService) SuccessResult

func (c *ContextService) SuccessResult(ctxId int64) int32

type Limits

type Limits struct {
	Cpu uint64
}

Limits describes the usage or limit of resources

func (*Limits) Add

func (l *Limits) Add(l1 Limits) *Limits

Add accumulates resource limits, returns self.

func (Limits) Exceed

func (l Limits) Exceed(l1 Limits) bool

Exceed judge whether resource exceeds l1

func (*Limits) Sub

func (l *Limits) Sub(l1 Limits) *Limits

Sub sub limits from l

type WxvmInstance

type WxvmInstance struct {
	ExecCtx exec.Context
	// contains filtered or unexported fields
}

func CreateInstance

func CreateInstance(contextId int64, code exec.Code, method string, contract *commonPb.Contract, gasUsed uint64,
	gasLimit int64) (*WxvmInstance, error)

func (*WxvmInstance) Abort

func (x *WxvmInstance) Abort(msg string)

func (*WxvmInstance) Exec

func (x *WxvmInstance) Exec() error

func (*WxvmInstance) Release

func (x *WxvmInstance) Release()

func (*WxvmInstance) ResourceUsed

func (x *WxvmInstance) ResourceUsed() Limits

Directories

Path Synopsis
Package pointer exchange pointer between cgo and go
Package pointer exchange pointer between cgo and go
runtime

Jump to

Keyboard shortcuts

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