Documentation
¶
Overview ¶
Package vm the contract execute environment
Index ¶
- Constants
- func CheckAddr(addr string) error
- func CheckContractCode(code string) error
- func CheckStateKey(key string) error
- func CheckStateKeyValue(key string, value []byte) error
- func CheckStateValue(value []byte) error
- func NewStateQueue() *stateQueue
- func NewTransferQueue() *transferQueue
- func PreExecute(tx *types.Transaction, cs *types.ContractSpec, ...) (bool, error)
- func Query(tx *types.Transaction, cs *types.ContractSpec, ...) ([]byte, error)
- func RealExecute(tx *types.Transaction, cs *types.ContractSpec, ...) (bool, error)
- type Config
- type ContractCode
- type ContractData
- type InvokeData
- type RequestHandleType
- type VMProc
- func (p *VMProc) CCallCommit() error
- func (p *VMProc) CCallCurrentBlockHeight() (uint32, error)
- func (p *VMProc) CCallDelState(key string) error
- func (p *VMProc) CCallGetBalances(addr string) (int64, error)
- func (p *VMProc) CCallGetState(key string) ([]byte, error)
- func (p *VMProc) CCallPutState(key string, value []byte) error
- func (p *VMProc) CCallSmartContractCommitted() error
- func (p *VMProc) CCallSmartContractFailed() error
- func (p *VMProc) CCallTransfer(recipientAddr string, amount int64, txType uint32) error
- func (p *VMProc) Close()
- func (p *VMProc) PCallPreExecute(cd *ContractData, handler contract.ISmartConstract) (bool, error)
- func (p *VMProc) PCallPreInitContract(cd *ContractData, handler contract.ISmartConstract) (bool, error)
- func (p *VMProc) PCallQueryContract(cd *ContractData, handler contract.ISmartConstract) ([]byte, error)
- func (p *VMProc) PCallRealExecute(cd *ContractData, handler contract.ISmartConstract) (bool, error)
- func (p *VMProc) PCallRealInitContract(cd *ContractData, handler contract.ISmartConstract) (bool, error)
- func (p *VMProc) Selector()
- func (p *VMProc) SendRequest(data *InvokeData) chan *InvokeData
- func (p *VMProc) SendResponse(data *InvokeData) error
- func (p *VMProc) SetRequestHandle(handle RequestHandleType)
Constants ¶
View Source
const ( InvokeTypeRequest = byte(1) InvokeTypeResponse = byte(2) )
request, response type
Variables ¶
This section is empty.
Functions ¶
func CheckContractCode ¶
func CheckStateKey ¶
func CheckStateKeyValue ¶
func CheckStateValue ¶
func NewStateQueue ¶
func NewStateQueue() *stateQueue
func NewTransferQueue ¶
func NewTransferQueue() *transferQueue
func PreExecute ¶
func PreExecute(tx *types.Transaction, cs *types.ContractSpec, handler contract.ISmartConstract) (bool, error)
PreExecute execute contract but not commit change(balances and state)
func Query ¶
func Query(tx *types.Transaction, cs *types.ContractSpec, handler contract.ISmartConstract) ([]byte, error)
func RealExecute ¶
func RealExecute(tx *types.Transaction, cs *types.ContractSpec, handler contract.ISmartConstract) (bool, error)
RealExecute execute contract and commit change(balances and state)
Types ¶
type Config ¶
type Config struct {
LogFile string
LogLevel string
VMRegistrySize int
VMCallStackSize int
VMMaxMem int // vm maximum memory size (MB)
ExecLimitStackDepth int
ExecLimitMaxOpcodeCount int // maximum allow execute opcode count
ExecLimitMaxRunTime int // the contract maximum run time (millisecond)
ExecLimitMaxScriptSize int // contract script(lua source code) maximum size (byte)
ExecLimitMaxStateValueSize int // the max state value size (byte)
ExecLimitMaxStateItemCount int // the max state count in one contract
ExecLimitMaxStateKeyLength int // max state key length
LuaVMExeFilePath string
JSVMExeFilePath string
}
Config vm config struct
var VMConf *Config
type ContractCode ¶
type ContractData ¶
type ContractData struct {
ContractCode string
ContractAddr string
ContractParams []string
Transaction *types.Transaction
}
func NewContractData ¶
func NewContractData(tx *types.Transaction, cs *types.ContractSpec, contractCode string) *ContractData
type InvokeData ¶
InvokeData request and response data
func (*InvokeData) DecodeParams ¶
func (data *InvokeData) DecodeParams(dataObj ...interface{}) error
func (*InvokeData) SetParams ¶
func (data *InvokeData) SetParams(params ...interface{})
type RequestHandleType ¶
type RequestHandleType func(vmproc *VMProc, data *InvokeData) (interface{}, error)
type VMProc ¶
type VMProc struct {
Proc *os.Process
PeerProc *os.Process
PipeWriter *os.File
PipeReader *os.File
Files []*os.File
StartTime time.Time
Lang string
Running bool
RequestHandle RequestHandleType
ContractData *ContractData
L0Handler contract.ISmartConstract
RequestMap map[uint32]chan *InvokeData
StateChangeQueue *stateQueue
TransferQueue *transferQueue
SessionID uint32
// contains filtered or unexported fields
}
VMProc the vm process struct
func FindVMProcess ¶
FindVMProcess find vm process from child proc
func (*VMProc) CCallCommit ¶
func (*VMProc) CCallCurrentBlockHeight ¶
func (*VMProc) CCallDelState ¶
func (*VMProc) CCallSmartContractCommitted ¶
func (*VMProc) CCallSmartContractFailed ¶
func (*VMProc) CCallTransfer ¶
func (*VMProc) Close ¶
func (p *VMProc) Close()
Close close the vm process and release all resources
func (*VMProc) PCallPreExecute ¶
func (p *VMProc) PCallPreExecute(cd *ContractData, handler contract.ISmartConstract) (bool, error)
func (*VMProc) PCallPreInitContract ¶
func (p *VMProc) PCallPreInitContract(cd *ContractData, handler contract.ISmartConstract) (bool, error)
func (*VMProc) PCallQueryContract ¶
func (p *VMProc) PCallQueryContract(cd *ContractData, handler contract.ISmartConstract) ([]byte, error)
func (*VMProc) PCallRealExecute ¶
func (p *VMProc) PCallRealExecute(cd *ContractData, handler contract.ISmartConstract) (bool, error)
func (*VMProc) PCallRealInitContract ¶
func (p *VMProc) PCallRealInitContract(cd *ContractData, handler contract.ISmartConstract) (bool, error)
func (*VMProc) SendRequest ¶
func (p *VMProc) SendRequest(data *InvokeData) chan *InvokeData
func (*VMProc) SendResponse ¶
func (p *VMProc) SendResponse(data *InvokeData) error
func (*VMProc) SetRequestHandle ¶
func (p *VMProc) SetRequestHandle(handle RequestHandleType)
Click to show internal directories.
Click to hide internal directories.