-
Notifications
You must be signed in to change notification settings - Fork 1
/
type_base.go
47 lines (39 loc) · 1.08 KB
/
type_base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package types
import (
"context"
)
// IType is the interface of all runtime types
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)
}
type HostContext interface {
RemainingGas() uint64
SetGas(gas uint64)
}
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
}
type Logger interface {
Debug(msg string, keyvals ...interface{})
Info(msg string, keyvals ...interface{})
Error(msg string, keyvals ...interface{})
}
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
}