-
Notifications
You must be signed in to change notification settings - Fork 9
/
base.go
93 lines (75 loc) · 1.88 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package base
import (
fcom "github.com/meshplus/hyperbench-common/common"
"github.com/op/go-logging"
)
// VMBase the base vm for support base config.
type VMBase struct {
ConfigBase
Logger *logging.Logger
}
// Type return the vm type.
func (v *VMBase) Type() string {
return "base"
}
// Close close vm.
func (v *VMBase) Close() {
}
// BeforeDeploy will call before deploy contract.
func (v *VMBase) BeforeDeploy() error {
return nil
}
// DeployContract deploy contract.
func (v *VMBase) DeployContract() error {
return nil
}
// BeforeGet will call before get context.
func (v *VMBase) BeforeGet() error {
return nil
}
// GetContext generate context for execute tx in vm.
func (v *VMBase) GetContext() ([]byte, error) {
return []byte(""), nil
}
// Statistic statistic remote execute info.
func (v *VMBase) Statistic(from, to int64) (*fcom.RemoteStatistic, error) {
return &fcom.RemoteStatistic{}, nil
}
// LogStatus records blockheight and time
func (v *VMBase) LogStatus() (int64, error) {
return 0, nil
}
// BeforeSet will call before set context.
func (v *VMBase) BeforeSet() error {
return nil
}
// SetContext set context for execute tx in vm, the ctx is generated by GetContext.
func (v *VMBase) SetContext(ctx []byte) error {
return nil
}
// BeforeRun will call once before run.
func (v *VMBase) BeforeRun() error {
return nil
}
// Run create and send tx to client.
func (v *VMBase) Run(ctx fcom.TxContext) (*fcom.Result, error) {
return &fcom.Result{}, nil
}
// AfterRun will call once after run.
func (v *VMBase) AfterRun() error {
return nil
}
// ConfigBase define base config in vm.
type ConfigBase struct {
// Path is the path of script file
Path string
// Ctx is the context of vm
Ctx fcom.VMContext
}
// NewVMBase use given config create VMBase.
func NewVMBase(config ConfigBase) *VMBase {
return &VMBase{
ConfigBase: config,
Logger: fcom.GetLogger("vm"),
}
}