Documentation ¶
Index ¶
- Constants
- Variables
- type Module
- type Modules
- type Sandbox
- func (sbx *Sandbox) Compile(contract *contract.Contract) (string, error)
- func (sbx *Sandbox) Execute(preparedCode string) (string, int64, error)
- func (sbx *Sandbox) GetFlags() int64
- func (sbx *Sandbox) Init(vmType vmPoolType)
- func (sbx *Sandbox) Prepare(contract *contract.Contract, function string, args []interface{}) (string, error)
- func (sbx *Sandbox) Release()
- func (sbx *Sandbox) SetGasLimit(limit int64)
- func (sbx *Sandbox) SetHost(host *host.Host)
- func (sbx *Sandbox) SetJSPath(path string, vmType vmPoolType)
- func (sbx *Sandbox) Validate(contract *contract.Contract) error
- type VM
- type VMPool
- func (vmp *VMPool) Compile(contract *contract.Contract) (string, error)
- func (vmp *VMPool) Init() error
- func (vmp *VMPool) LoadAndCall(host *host.Host, contract *contract.Contract, api string, args ...interface{}) (rtn []interface{}, cost contract.Cost, err error)
- func (vmp *VMPool) Release()
- func (vmp *VMPool) SetJSPath(path string)
- func (vmp *VMPool) Validate(contract *contract.Contract) error
Constants ¶
const ( // CompileVMPool maintains a pool of compile vm instance CompileVMPool vmPoolType = iota // RunVMPool maintains a pool of run vm instance RunVMPool )
Variables ¶
var ( ErrConsoleNoLogger = errors.New("no logger error") ErrConsoleInvalidLogLevel = errors.New("log invalid level") )
Error message
var CVMInitOnce = sync.Once{}
CVMInitOnce vm init once
var ( // ErrGetSandbox error when GetSandbox failed. ErrGetSandbox = errors.New("get sandbox failed") )
var ErrInvalidDbValType = errors.New("invalid db value type")
ErrInvalidDbValType error
var (
ErrResultTooLong = errors.New("result too long")
)
Error message
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module JavaScript module.
type Sandbox ¶
type Sandbox struct {
// contains filtered or unexported fields
}
Sandbox is an execution environment that allows separate, unrelated, JavaScript code to run in a single instance of IVM.
func GetSandbox ¶
func GetSandbox(cSbx C.SandboxPtr) (*Sandbox, bool)
GetSandbox from sandbox map by sandbox ptr
func NewSandbox ¶
NewSandbox generate new sandbox for VM and insert into sandbox map
func (*Sandbox) Prepare ¶
func (sbx *Sandbox) Prepare(contract *contract.Contract, function string, args []interface{}) (string, error)
Prepare for contract, inject code
func (*Sandbox) SetGasLimit ¶
SetGasLimit set gas limit in context
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM contains isolate instance, which is a v8 VM with its own heap.
func NewVMWithChannel ¶
NewVMWithChannel return new vm with release channel
func (*VM) EnsureFlags ¶
EnsureFlags make sandbox flag is same with input
type VMPool ¶
type VMPool struct {
// contains filtered or unexported fields
}
VMPool manage all V8VM instance.
func (*VMPool) LoadAndCall ¶
func (vmp *VMPool) LoadAndCall(host *host.Host, contract *contract.Contract, api string, args ...interface{}) (rtn []interface{}, cost contract.Cost, err error)
LoadAndCall load compiled Javascript code and run code with specified api and args