vm

package
v0.0.0-...-190a898 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: LGPL-3.0-or-later Imports: 1 Imported by: 0

Documentation

Overview

This file is part of the Dazzle Gravity library.

The Dazzle Gravity library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Dazzle Gravity library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Dazzle Gravity library. If not, see <e <http://www.gnu.org/licenses/>./>.

This file is part of the Dazzle Gravity library.

The Dazzle Gravity library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Dazzle Gravity library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Dazzle Gravity library. If not, see <e <http://www.gnu.org/licenses/>./>.

Index

Constants

View Source
const (
	//VMModeContract is VM contract execute mode
	VMModeContract = 0

	//VMModeRestrict is asset restrict mode
	VMModeRestrict = 1
)
View Source
const (
	//LispScriptCode is lisp code number
	LispScriptCode = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	//Debug marks if VM is working in debug mode
	Debug bool
	//MaxStep is the max steps of VM
	MaxStep uint32
	//Mode marks execute mode of VM
	Mode byte
}

Config is configuration of VM

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig creates a new default configuration object

func NewConfig

func NewConfig(debug bool, maxstep uint32) *Config

NewConfig creates a new VM configuration object

type Context

type Context struct {
	//TxUnit is unit information that is used when execute contract
	TxUnit structure.Unit

	//TxMsgIndex is message index that is used when execute contract
	TxMsgIndex uint32

	//AssetMsg is issue message that is used when execute contract
	AssetMsg structure.IssueMessage

	//FetchPrevOut is a callback function to fetch previous output associated with current input
	FetchPrevOut func(input *structure.ContractInput) *structure.ContractOutput

	//MCI is Main Chain Index of DAG that is used when execute contract
	MCI uint64

	//ContractDef is contract definition information
	ContractDef *structure.ContractDef

	//For Restrict
	//Input is contract input that is used when execute contract
	Input *structure.ContractInput
	// PrevOut is previous output unit info associate with current contract input
	PrevOut *structure.TxUtxo
}

Context is context of VM

func NewContext

func NewContext(unit structure.Unit, msgIndex uint32,
	assetMsg structure.IssueMessage,
	mci uint64, fetchOutput func(input *structure.ContractInput) *structure.ContractOutput) *Context

NewContext creates a new smart contract runtime environment object

func NewRestrictContext

func NewRestrictContext(unit structure.Unit, msgIndex uint32,
	assetMsg structure.IssueMessage,
	mci uint64, input *structure.ContractInput, prevOut *structure.TxUtxo) *Context

NewRestrictContext creates a new restrict mode context object

type VM

type VM interface {
	ID() uint32
	Version() uint16
	ScriptCode() byte

	Config() Config
	Context() Context

	Exec(contract structure.Contract) bool
	SetEnv(context Context, config Config)
}

VM is virtual machine interface

Directories

Path Synopsis
This file is part of the Dazzle Gravity library.
This file is part of the Dazzle Gravity library.

Jump to

Keyboard shortcuts

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