hvm

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 22 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ObjINT    = "java.lang.Integer"
	INT       = "int"
	ObjSHORT  = "java.lang.Short"
	SHORT     = "short"
	ObjLONG   = "java.lang.Long"
	LONG      = "long"
	ObjBYTE   = "java.lang.Byte"
	BYTE      = "byte"
	ObjFLOAT  = "java.lang.Float"
	FLOAT     = "float"
	ObjDOUBLE = "java.lang.Double"
	DOUBLE    = "double"
	ObjCHAR   = "java.lang.Character"
	CHAR      = "char"
	ObjBOOL   = "java.lang.Boolean"
	BOOL      = "boolean"
	STRING    = "java.lang.String"
	OBJECT    = "java.lang.Object"
)
View Source
const (
	HyperListClassRef  = "cn/hyperchain/core/HyperList"
	HyperListFieldRef  = "Lcn/hyperchain/core/HyperList;"
	HyperMapClassRef   = "cn/hyperchain/core/HyperMap"
	HyperMapFieldRef   = "Lcn/hyperchain/core/HyperMap;"
	HyperTableClassRef = "cn/hyperchain/core/HyperTable"
	HyperTableFieldRef = "Lcn/hyperchain/core/HyperTable;"

	IntegerJ   = "Ljava/lang/Integer;"
	BooleanJ   = "Ljava/lang/Boolean;"
	ByteJ      = "Ljava/lang/Byte;"
	CharacterJ = "Ljava/lang/Character;"
	DoubleJ    = "Ljava/lang/Double;"
	FloatJ     = "Ljava/lang/Float;"
	LongJ      = "Ljava/lang/Long;"
	ShortJ     = "Ljava/lang/Short;"
	StringJ    = "Ljava/lang/String;"

	NULL = "null"
)
View Source
const (
	ContractManifestPath = "META-INF/MANIFEST.MF"
	ContractClassSuffix  = ".class"
)

Variables

View Source
var (
	NameAndType = []string{"name", "type", "value"}
	Contract    *ObjectType
	ClassMap    map[string]*classfile.ClassFile
	MainClass   string
	DBStorage   *leveldb.DB
)

Functions

func BytesToInt32

func BytesToInt32(bytes []byte) int32

func Convert

func Convert(fc interface{}) interface{}

func DataStringToBytes

func DataStringToBytes(str string, sep string) [][]byte

func DecompressJar

func DecompressJar(filepath string) ([]byte, error)

func GenPayload

func GenPayload(beanAbi *BeanAbi, params ...interface{}) ([]byte, error)

func GetLdbConfig

func GetLdbConfig() *opt.Options

func GetLdbDefaultConfig

func GetLdbDefaultConfig() *opt.Options

func InitContract

func InitContract(contractCode []byte)

func IntToBytes2

func IntToBytes2(i int) [2]byte

func IntToBytes4

func IntToBytes4(i int) [4]byte

IntToBytes4 convert int to [4]byte NOTE: i should less than 2^31

func IsBaseType

func IsBaseType(class string) bool

func IsPrimitiveType

func IsPrimitiveType(class string) bool

func OpenDB

func OpenDB(path string) *leveldb.DB

func ParseContractData

func ParseContractData(contract *ObjectType, classFile *classfile.ClassFile, contractAddress string, db bool, dbPath string, source map[string]map[string][]byte)

func ParseHistoryData

func ParseHistoryData(contract *ObjectType, classFile *classfile.ClassFile, contractAddress string, dbPath string)

func ParseIncrementData

func ParseIncrementData(contract *ObjectType, classFile *classfile.ClassFile, contractAddress, mqLog string)

func ReadJar

func ReadJar(path string) (string, error)

func ReadZipFile

func ReadZipFile(zipf *zip.File) ([]byte, error)

ReadZipFile read a file data from a zip

func Reset

func Reset()

Types

type Abi

type Abi []BeanAbi

func GenAbi

func GenAbi(abiJson string) (Abi, error)

func (Abi) GetBeanAbi

func (abi Abi) GetBeanAbi(beanName string) (*BeanAbi, error)

func (Abi) GetMethodAbi

func (abi Abi) GetMethodAbi(methodName string) (*BeanAbi, error)

type ArrayType

type ArrayType struct {
	CommonType
	Dimension int
	Fields    []FieldType
}

type BaseType

type BaseType struct {
	CommonType
}

type BeanAbi

type BeanAbi struct {
	BeanVersion Version  `json:"version"`
	BeanName    string   `json:"beanName"`
	Inputs      []Entry  `json:"inputs"`
	Output      Entry    `json:"output"`
	ClassBytes  string   `json:"classBytes"`
	Structs     []Entry  `json:"structs"`
	BeanType    BeanType `json:"beanType"`
}

type BeanType

type BeanType string

bean type

const (
	InvokeBean BeanType = "InvokeBean"
	MethodBean BeanType = "MethodBean"
)

type Body

type Body struct {
	Type string
	Name string
	Data map[string]map[string][]byte
}

type CommonType

type CommonType struct {
	Name    string
	Class   string
	Columns []string
	Value   string
}

type Entry

type Entry struct {
	Name       string  `json:"name"`
	EntryType  Type    `json:"type"`
	Properties []Entry `json:"properties,omitempty"`
	StructName string  `json:"structName,omitempty"`
}

type FieldType

type FieldType interface {
}

func NewFieldType

func NewFieldType(class string) FieldType

NewFieldType create FieldType with class name

type HvmLog

type HvmLog struct {
	Timestamp uint64
	Type      string
	Body      Body
}

type HyperList

type HyperList struct {
	CommonType

	Fields []FieldType
	// contains filtered or unexported fields
}

type HyperMap

type HyperMap struct {
	CommonType
	KFields []FieldType
	VFields []FieldType
}

type HyperTable

type HyperTable struct {
	CommonType
	Columns map[string]map[string]bool
	Items   []TableItem
}

type KVTemplate

type KVTemplate struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type ListData

type ListData struct {
	Table []uint64
	Count uint64
}

type ObjectType

type ObjectType struct {
	CommonType
	Fields []FieldType
}

type ParamBuilder

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

func NewParamBuilder

func NewParamBuilder(s string) *ParamBuilder

func (*ParamBuilder) AddBoolean

func (p *ParamBuilder) AddBoolean(s bool) *ParamBuilder

func (*ParamBuilder) AddByte

func (p *ParamBuilder) AddByte(s byte) *ParamBuilder

func (*ParamBuilder) AddCharacter

func (p *ParamBuilder) AddCharacter(s uint16) *ParamBuilder

func (*ParamBuilder) AddDouble

func (p *ParamBuilder) AddDouble(s float64) *ParamBuilder

func (*ParamBuilder) AddFloat

func (p *ParamBuilder) AddFloat(s float32) *ParamBuilder

func (*ParamBuilder) AddInteger

func (p *ParamBuilder) AddInteger(s int) *ParamBuilder

func (*ParamBuilder) AddLong

func (p *ParamBuilder) AddLong(s int64) *ParamBuilder

func (*ParamBuilder) AddObject

func (p *ParamBuilder) AddObject(clazz string, s interface{}) *ParamBuilder

func (*ParamBuilder) AddShort

func (p *ParamBuilder) AddShort(s int16) *ParamBuilder

func (*ParamBuilder) AddString

func (p *ParamBuilder) AddString(s string) *ParamBuilder

func (*ParamBuilder) Addbool

func (p *ParamBuilder) Addbool(s bool) *ParamBuilder

func (*ParamBuilder) Addbyte

func (p *ParamBuilder) Addbyte(s byte) *ParamBuilder

func (*ParamBuilder) Addchar

func (p *ParamBuilder) Addchar(s uint16) *ParamBuilder

func (*ParamBuilder) Adddouble

func (p *ParamBuilder) Adddouble(s float64) *ParamBuilder

func (*ParamBuilder) Addfloat

func (p *ParamBuilder) Addfloat(s float32) *ParamBuilder

func (*ParamBuilder) Addint

func (p *ParamBuilder) Addint(s int) *ParamBuilder

func (*ParamBuilder) Addlong

func (p *ParamBuilder) Addlong(s int64) *ParamBuilder

func (*ParamBuilder) Addshort

func (p *ParamBuilder) Addshort(s int16) *ParamBuilder

func (*ParamBuilder) Build

func (p *ParamBuilder) Build() []byte

func (*ParamBuilder) CreateMethod

func (p *ParamBuilder) CreateMethod(s string) *ParamBuilder

type PayLoad added in v1.1.0

type PayLoad struct {
	InvokeBeanName string   `json:"invokeBeanName"`
	InvokeArgs     string   `json:"invokeArgs"`
	InvokeMethods  []string `json:"invokeMethods"`
}

func DecodePayload added in v1.1.0

func DecodePayload(pl string) (*PayLoad, error)

type TableItem

type TableItem struct {
	Row          string
	ColumnFamily string
	Column       string
	Value        string
}

type Type

type Type string

abi type

const (
	Void   Type = "Void"
	Bool   Type = "Bool"
	Char   Type = "Char"
	Byte   Type = "Byte"
	Short  Type = "Short"
	Int    Type = "Int"
	Long   Type = "Long"
	Float  Type = "Float"
	Double Type = "Double"
	String Type = "String"
	Array  Type = "Array"
	List   Type = "List"
	Map    Type = "Map"
	Struct Type = "Struct"
)

type Version

type Version string

abi version

const (
	Version1 Version = "v1"
)

Jump to

Keyboard shortcuts

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