types

package
v0.4.7-rc7 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	HeaderDataType = 2
	HeaderDataLen  = 4
	HeaderLen      = 6
)
View Source
const (
	EVMGasToWASMGasMultiplier = 100
	MaxGas                    = math.MaxInt64 / EVMGasToWASMGasMultiplier
)

Variables

View Source
var (
	OutOfGasError = errors.New("out of gas")
)

Functions

This section is empty.

Types

type AspectRuntime

type AspectRuntime interface {
	Call(method string, gas int64, args ...interface{}) (interface{}, int64, error)
	Destroy()
	ResetStore(ctx context.Context, apis *HostAPIRegistry) error
	Context() context.Context
	Logger() Logger
}

type BaseGasRule

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

func (*BaseGasRule) SetContext

func (r *BaseGasRule) SetContext(ctx VMContext)

type Bool

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

func NewBool

func NewBool() *Bool

func (*Bool) Marshal

func (t *Bool) Marshal(value interface{}) []byte

func (*Bool) Unmarshal

func (t *Bool) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type ByteArray

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

ByteArray implements IType

func NewByteArrary

func NewByteArrary() *ByteArray

func (*ByteArray) Marshal

func (t *ByteArray) Marshal(value interface{}) []byte

func (*ByteArray) Unmarshal

func (t *ByteArray) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type DynamicGasRule

type DynamicGasRule struct {
	BaseGasRule
	// contains filtered or unexported fields
}

func NewDynamicGasRule

func NewDynamicGasRule(fixedCost int64, multiplier int64) *DynamicGasRule

func (*DynamicGasRule) ConsumeGas

func (d *DynamicGasRule) ConsumeGas(dataSize int64) error

type HostAPIRegistry

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

func NewHostAPIRegistry

func NewHostAPIRegistry(hostFuncWrapper HostFuncWrapper) *HostAPIRegistry

func (*HostAPIRegistry) AddAPI

func (h *HostAPIRegistry) AddAPI(module Module, ns NameSpace, method MethodName, hostFunc *HostFuncWithGasRule) error

func (*HostAPIRegistry) Context

func (h *HostAPIRegistry) Context() VMContext

func (*HostAPIRegistry) Destroy

func (h *HostAPIRegistry) Destroy()

func (*HostAPIRegistry) SetContext

func (h *HostAPIRegistry) SetContext(ctx VMContext)

func (*HostAPIRegistry) WrapperFuncs

func (h *HostAPIRegistry) WrapperFuncs() map[Module]map[NameSpace]map[MethodName]interface{}

type HostContext

type HostContext interface {
	RemainingGas() uint64
	SetGas(gas uint64)
}

type HostFuncGasRule

type HostFuncGasRule interface {
	SetContext(ctx VMContext)
	ConsumeGas(dataSize int64) error
}

type HostFuncWithGasRule

type HostFuncWithGasRule struct {
	Func        interface{}
	GasRule     HostFuncGasRule
	HostContext HostContext
}

type HostFuncWrapper

type HostFuncWrapper func(api *HostAPIRegistry, module Module, ns NameSpace, method MethodName, hostFunc *HostFuncWithGasRule) (interface{}, error)

type IType

type IType interface {
	// Marshal serialize the type to byte array
	Marshal(value interface{}) []byte

	// Unmarshal desialize the data to the type
	Unmarshal(data []byte) (interface{}, error)
}

IType is the interface of all runtime types

func TypeObjectMapping

func TypeObjectMapping(index TypeIndex) (IType, error)

type Int32

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

func NewInt32

func NewInt32() *Int32

func (*Int32) Marshal

func (t *Int32) Marshal(value interface{}) []byte

func (*Int32) Unmarshal

func (t *Int32) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type Int64

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

func NewInt64

func NewInt64() *Int64

func (*Int64) Marshal

func (t *Int64) Marshal(value interface{}) []byte

func (*Int64) Unmarshal

func (t *Int64) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type Logger

type Logger interface {
	Debug(msg string, keyvals ...interface{})
	Info(msg string, keyvals ...interface{})
	Error(msg string, keyvals ...interface{})
}

type MethodName

type MethodName string

type Module

type Module string

type NameSpace

type NameSpace string

type StaticGasRule

type StaticGasRule struct {
	BaseGasRule
	// contains filtered or unexported fields
}

func NewStaticGasRule

func NewStaticGasRule(cost int64) *StaticGasRule

func (*StaticGasRule) ConsumeGas

func (s *StaticGasRule) ConsumeGas(_ int64) error

type String

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

String implements IType

func NewString

func NewString() *String

func (*String) Marshal

func (t *String) Marshal(value interface{}) []byte

func (*String) Unmarshal

func (t *String) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type TypeHeader

type TypeHeader struct{}

func (*TypeHeader) Marshal

func (t *TypeHeader) Marshal(dataType TypeIndex, dataLen int32) []byte

func (*TypeHeader) Unmarshal

func (t *TypeHeader) Unmarshal(data []byte) (dataType TypeIndex, dataLen int32, err error)

Unmarshal desialize the data to the type

type TypeIndex

type TypeIndex int16

TypeIndex defines the index of runtime type

const (
	TypeEmpty TypeIndex = iota // wrong type, no handler for empty type
	TypeInt8
	TypeInt16
	TypeInt32
	TypeInt64
	TypeUint8
	TypeUint16
	TypeUint32
	TypeUint64
	TypeBool
	TypeString // string with utf-8 encoder
	TypeByteArray
)

func AssertType

func AssertType(v interface{}) TypeIndex

type Uint64

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

func NewUint64

func NewUint64() *Uint64

func (*Uint64) Marshal

func (t *Uint64) Marshal(value interface{}) []byte

func (*Uint64) Unmarshal

func (t *Uint64) Unmarshal(data []byte) (interface{}, error)

Unmarshal desialize the data to the type

type VMContext

type VMContext interface {
	context.Context

	WriteMemory(ptr int32, data []byte) error
	ReadMemory(ptr int32, size int32) ([]byte, error)
	AllocMemory(size int32) (int32, error)
	RemainingEVMGas() (int64, error)
	RemainingWASMGas() (int64, error)
	ConsumeWASMGas(gas int64) error
	AddEVMGas(gas int64) error
	SetWASMGas(gas int64) error
	Logger() Logger
}

Jump to

Keyboard shortcuts

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