runtime

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppFlagRun the app can be call
	AppFlagRun = uint8(1 << iota)
	// AppFlagImport the app code can be included
	AppFlagImport
	// AppFlagPlublc App funds address uses the plublc address, except for app, others have no right to operate the address.
	AppFlagPlublc
	// AppFlagGzipCompress gzip compress
	AppFlagGzipCompress
	// AppFlagEnd end of flag
	AppFlagEnd
)
View Source
const (
	EncBinary = uint8(iota)
	EncJSON
	EncGob
)

encoding type

Variables

This section is empty.

Functions

func AdminDbSet

func AdminDbSet(owner interface{}, chain uint64, key, value []byte, life uint64) error

AdminDbSet write data to the chain

func DbExist

func DbExist(owner interface{}, chain uint64, key []byte) bool

DbExist return true if exist

func DbGet

func DbGet(owner interface{}, chain uint64, key []byte) ([]byte, uint64)

DbGet get data form db

func Decode

func Decode(in []byte, out interface{}) int

Decode 将字符流填充到指定结构体

func Encode

func Encode(in interface{}) []byte

Encode 将interface{}转成字符流,不支持可变长度类型

func GetAppName added in v0.3.2

func GetAppName(owner interface{}) []byte

GetAppName 用app的私有结构体,获取app的Hash名字

func GetFullPathOfApp

func GetFullPathOfApp(chain uint64, name []byte) string

GetFullPathOfApp get the full path of app

func GetHash

func GetHash(in []byte) []byte

GetHash 计算hash值

func GetNextKey added in v0.3.2

func GetNextKey(chain uint64, isDb bool, appName, structName string, preKey []byte) []byte

GetNextKey get next key

func GetPackPath

func GetPackPath(chain uint64, name []byte) string

GetPackPath get the package path on golang packages

func GetStructName

func GetStructName(owner interface{}) []byte

GetStructName 通过包的私有对象,获取私有对象名字

func GetValue added in v0.3.2

func GetValue(chain uint64, isDb bool, appName, structName string, key []byte) ([]byte, uint64)

GetValue get value of key

func GobDecode added in v0.3.2

func GobDecode(in []byte, out interface{}) int

GobDecode gob decode

func GobEncode added in v0.3.2

func GobEncode(in interface{}) []byte

GobEncode gob encode

func JSONDecode added in v0.3.2

func JSONDecode(in []byte, out interface{}) int

JSONDecode decode json

func JSONEncode added in v0.3.2

func JSONEncode(in interface{}) []byte

JSONEncode encode json

func LogRead

func LogRead(owner interface{}, chain uint64, key []byte) ([]byte, uint64)

LogRead get data form log db

func NewApp

func NewApp(chain uint64, name []byte, code []byte)

NewApp 创建app

func RebuildApp added in v0.3.9

func RebuildApp(chain uint64, dir string) error

RebuildApp rebuild app

func RunApp

func RunApp(client *client.Client, flag []byte, chain uint64, mode string, appName, user, data []byte, energy, cost uint64)

RunApp run app

Types

type EventFilter

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

EventFilter event filter, show or drop app event

type TAppInfo

type TAppInfo struct {
	AppName  string
	PackPath string
	CorePath string
	ChainID  uint64
}

TAppInfo app info

type TAppNewHead

type TAppNewHead struct {
	LineNum   uint32
	Type      uint16
	Flag      uint8
	DependNum uint8
}

TAppNewHead 新建app的头消息,不包含依赖列表

type TAppNewInfo

type TAppNewInfo struct {
	TAppNewHead
	Depends []TDependItem
}

TAppNewInfo 新建app的信息,不包含依赖列表

type TDependItem

type TDependItem struct {
	Alias   [4]byte
	AppName [32]byte
}

TDependItem app的依赖信息

type TRunParam

type TRunParam struct {
	Chain     uint64
	Flag      []byte
	User      []byte
	Data      []byte
	Cost      uint64
	Energy    uint64
	ErrorInfo string
}

TRunParam Run接口的入参

type TRuntime

type TRuntime struct {
	Chain uint64
	Flag  []byte
	// contains filtered or unexported fields
}

TRuntime 执行机的结构体定义

func NewRuntime added in v0.3.9

func NewRuntime(addrType, address string) *TRuntime

NewRuntime input address of database

func (*TRuntime) ConsumeEnergy

func (r *TRuntime) ConsumeEnergy(energy uint64)

ConsumeEnergy consume energy

func (*TRuntime) DbGet

func (r *TRuntime) DbGet(owner interface{}, key []byte) ([]byte, uint64)

DbGet 数据库读取数据

func (*TRuntime) DbGetLife

func (r *TRuntime) DbGetLife(owner interface{}, key []byte) uint64

DbGetLife get life of the db data

func (*TRuntime) DbSet

func (r *TRuntime) DbSet(owner interface{}, key, value []byte, life uint64)

DbSet 数据库保存数据

func (*TRuntime) Decode

func (r *TRuntime) Decode(typ uint8, in []byte, out interface{}) int

Decode 将字符流填充到指定结构体

func (*TRuntime) Encode

func (r *TRuntime) Encode(typ uint8, in interface{}) []byte

Encode 将interface{}转成字符流,不支持可变长度类型

func (*TRuntime) Event

func (r *TRuntime) Event(user interface{}, event string, param ...[]byte)

Event event

func (*TRuntime) GetAppName

func (r *TRuntime) GetAppName(owner interface{}) []byte

GetAppName 用app的私有结构体,获取app的Hash名字

func (*TRuntime) GetHash

func (r *TRuntime) GetHash(in []byte) []byte

GetHash 计算hash值

func (*TRuntime) JSONDecode

func (r *TRuntime) JSONDecode(in []byte, out interface{})

JSONDecode 将json格式的字符串转成结构体

func (*TRuntime) JSONEncode

func (r *TRuntime) JSONEncode(in interface{}) []byte

JSONEncode 将结构体转成json格式的字符串

func (*TRuntime) LogRead

func (r *TRuntime) LogRead(owner interface{}, chain uint64, key []byte) ([]byte, uint64)

LogRead The reading interface of the log

func (*TRuntime) LogReadLife

func (r *TRuntime) LogReadLife(owner interface{}, key []byte) uint64

LogReadLife get life of the log data

func (*TRuntime) LogWrite

func (r *TRuntime) LogWrite(owner interface{}, key, value []byte, life uint64)

LogWrite log write

func (*TRuntime) NewApp

func (r *TRuntime) NewApp(name []byte, code []byte)

NewApp 新建app,返回可运行的代码行数

func (*TRuntime) OtherOps

func (r *TRuntime) OtherOps(user interface{}, ops int, data []byte) []byte

OtherOps extesion api

func (*TRuntime) Recover

func (r *TRuntime) Recover(address, sign, msg []byte) bool

Recover 校验签名信息

func (*TRuntime) RunApp

func (r *TRuntime) RunApp(name, user, data []byte, energy, cost uint64)

RunApp 执行app,返回执行的指令数量

func (*TRuntime) SetInfo

func (r *TRuntime) SetInfo(chain uint64, flag []byte)

SetInfo 设置参数

func (*TRuntime) SetTestMode added in v0.3.2

func (r *TRuntime) SetTestMode()

SetTestMode set test mode,it will not write data to database

Jump to

Keyboard shortcuts

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