-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.go
89 lines (72 loc) · 2.17 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
package base
import (
"github.com/meshplus/hyperbench-common/common"
"github.com/op/go-logging"
)
// BlockchainBase the base implementation of blockChain.
type BlockchainBase struct {
ClientConfig
Logger *logging.Logger
}
// ClientConfig define the filed for client config.
type ClientConfig struct {
// client
ClientType string `mapstructure:"type"`
ConfigPath string `mapstructure:"config"`
// contract
ContractPath string `mapstructure:"contract"`
Args []interface{} `mapstructure:"args"`
// options
Options map[string]interface{} `mapstructure:"options"`
}
// Confirm confirm invoke result for tx.
func (b *BlockchainBase) Confirm(result *common.Result, ops ...common.Option) *common.Result {
return result
}
// DeployContract send tx for deploy contract.
func (b *BlockchainBase) DeployContract() error {
return nil
}
// Invoke send tx for invoke contract.
func (b *BlockchainBase) Invoke(common.Invoke, ...common.Option) *common.Result {
return &common.Result{}
}
// Transfer send tx for transfer.
func (b *BlockchainBase) Transfer(common.Transfer, ...common.Option) *common.Result {
return &common.Result{}
}
// Query query info.
func (b *BlockchainBase) Query(common.Query, ...common.Option) interface{} {
return nil
}
// Option receive some options.
func (b *BlockchainBase) Option(common.Option) error {
return nil
}
// GetContext get context for execute tx in vm.
func (b *BlockchainBase) GetContext() (string, error) {
return "", nil
}
// SetContext set context for execute tx in vm.
func (b *BlockchainBase) SetContext(ctx string) error {
return nil
}
// ResetContext reset context.
func (b *BlockchainBase) ResetContext() error {
return nil
}
// Statistic statistic remote execute result.
func (b *BlockchainBase) Statistic(statistic common.Statistic) (*common.RemoteStatistic, error) {
return &common.RemoteStatistic{}, nil
}
// LogStatus records blockheight and time
func (b *BlockchainBase) LogStatus() (int64, error) {
return 0, nil
}
// NewBlockchainBase new blockchain base.
func NewBlockchainBase(clientConfig ClientConfig) *BlockchainBase {
return &BlockchainBase{
ClientConfig: clientConfig,
Logger: common.GetLogger("client"),
}
}