vm

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContractCodeKey = "__CONTRACT_CODE_KEY__"
)

Variables

View Source
var (
	ErrNoValidParamsCnt = errors.New("invalid param count")
)

Functions

func CheckAddr

func CheckAddr(addr string) error

func CheckStateKey

func CheckStateKey(key string) error

func CheckStateKeyValue

func CheckStateKeyValue(key string, value []byte) error

func CheckStateValue

func CheckStateValue(value []byte) error

func CheckVmMem

func CheckVmMem(mem int) error

func ConcrateStateJson

func ConcrateStateJson(v interface{}) (*bytes.Buffer, error)

func DoContractStateData

func DoContractStateData(src []byte) ([]byte, error)

func NewStateQueue

func NewStateQueue() *stateQueue

func NewTransferQueue

func NewTransferQueue() *transferQueue

Types

type BVMEngine

type BVMEngine interface {
}

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
	BsWorkerCnt                int
	JsWorkerCnt                int
	LuaWorkerCnt               int
}

Config vm config struct

var VMConf *Config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig default vm config

func (*Config) SetString

func (c *Config) SetString(src string) error

func (*Config) String

func (c *Config) String() string

type ContractCode

type ContractCode struct {
	Code []byte
	Type string
}

type ContractData

type ContractData struct {
	ContractCode   string
	ContractAddr   string
	ContractParams []string
	Transaction    *proto.Transaction
}

func NewContractData

func NewContractData(tx *proto.Transaction) *ContractData

type ISmartConstract

type ISmartConstract interface {
	GetGlobalState(key string) ([]byte, error)

	PutGlobalState(key string, value []byte) error

	DelGlobalState(key string) error

	GetState(key string) ([]byte, error)

	PutState(key string, value []byte) error

	DelState(key string) error

	ComplexQuery(key string) ([]byte, error)

	GetBalance(addr string, assetID uint32) (int64, error)

	GetCurrentBlockHeight() uint32

	AddTransfer(fromAddr, toAddr string, assetID uint32, amount, fee int64) error

	Transfer(tx *proto.Transaction) error

	GetBalances(addr string) (*ltyes.Balance, error)

	//GetByRange(startKey, limitKey string) ([]*db.KeyValue, error)
	CallBack(response *state.CallBackResponse) error
}

blockchain should provide the implement to VM

type TxSync

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

For handle the transacton concurrency processing, to ensure the order of the transaction

var Txsync *TxSync

func NewTxSync

func NewTxSync(workersCnt int) *TxSync

func (*TxSync) Notify

func (ts *TxSync) Notify(idx int)

func (*TxSync) Wait

func (ts *TxSync) Wait(idx int)

type WorkerProc

type WorkerProc struct {
	ContractData     *ContractData
	SCHandler        ISmartConstract
	StateChangeQueue *stateQueue
	TransferQueue    *transferQueue
}

func (*WorkerProc) CCallCommit

func (p *WorkerProc) CCallCommit() error

func (*WorkerProc) CCallComplexQuery

func (p *WorkerProc) CCallComplexQuery(key string) ([]byte, error)

func (*WorkerProc) CCallCurrentBlockHeight

func (p *WorkerProc) CCallCurrentBlockHeight() (uint32, error)

func (*WorkerProc) CCallDelGlobalState

func (p *WorkerProc) CCallDelGlobalState(key string) error

func (*WorkerProc) CCallDelState

func (p *WorkerProc) CCallDelState(key string) error

func (*WorkerProc) CCallGetBalance

func (p *WorkerProc) CCallGetBalance(addr string, assetID uint32) (int64, error)

func (*WorkerProc) CCallGetBalances

func (p *WorkerProc) CCallGetBalances(addr string) (*ltyes.Balance, error)

func (*WorkerProc) CCallGetGlobalState

func (p *WorkerProc) CCallGetGlobalState(key string) ([]byte, error)

func (*WorkerProc) CCallGetState

func (p *WorkerProc) CCallGetState(key string) ([]byte, error)

func (*WorkerProc) CCallPutState

func (p *WorkerProc) CCallPutState(key string, value []byte) error

func (*WorkerProc) CCallSetGlobalState

func (p *WorkerProc) CCallSetGlobalState(key string, value []byte) error

func (*WorkerProc) CCallSmartContractCommitted

func (p *WorkerProc) CCallSmartContractCommitted() error

func (*WorkerProc) CCallSmartContractFailed

func (p *WorkerProc) CCallSmartContractFailed() error

func (*WorkerProc) CCallTransfer

func (p *WorkerProc) CCallTransfer(recipientAddr string, id, amount int64, fee int64) error

type WorkerProcWithCallback

type WorkerProcWithCallback struct {
	WorkProc *WorkerProc
	Idx      int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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