@@ -14,86 +14,65 @@ import (
14
14
"github.com/ava-labs/avalanchego/utils/rpc"
15
15
)
16
16
17
- var _ Client = (* client )(nil )
18
-
19
- // Client interface for the Avalanche Platform Info API Endpoint
20
- type Client interface {
21
- StartCPUProfiler (context.Context , ... rpc.Option ) error
22
- StopCPUProfiler (context.Context , ... rpc.Option ) error
23
- MemoryProfile (context.Context , ... rpc.Option ) error
24
- LockProfile (context.Context , ... rpc.Option ) error
25
- Alias (ctx context.Context , endpoint string , alias string , options ... rpc.Option ) error
26
- AliasChain (ctx context.Context , chainID string , alias string , options ... rpc.Option ) error
27
- GetChainAliases (ctx context.Context , chainID string , options ... rpc.Option ) ([]string , error )
28
- Stacktrace (context.Context , ... rpc.Option ) error
29
- LoadVMs (context.Context , ... rpc.Option ) (map [ids.ID ][]string , map [ids.ID ]string , error )
30
- SetLoggerLevel (ctx context.Context , loggerName , logLevel , displayLevel string , options ... rpc.Option ) (map [string ]LogAndDisplayLevels , error )
31
- GetLoggerLevel (ctx context.Context , loggerName string , options ... rpc.Option ) (map [string ]LogAndDisplayLevels , error )
32
- GetConfig (ctx context.Context , options ... rpc.Option ) (interface {}, error )
33
- DBGet (ctx context.Context , key []byte , options ... rpc.Option ) ([]byte , error )
17
+ type Client struct {
18
+ Requester rpc.EndpointRequester
34
19
}
35
20
36
- // Client implementation for the Avalanche Platform Info API Endpoint
37
- type client struct {
38
- requester rpc.EndpointRequester
39
- }
40
-
41
- // NewClient returns a new Info API Client
42
- func NewClient (uri string ) Client {
43
- return & client {requester : rpc .NewEndpointRequester (
21
+ func NewClient (uri string ) * Client {
22
+ return & Client {Requester : rpc .NewEndpointRequester (
44
23
uri + "/ext/admin" ,
45
24
)}
46
25
}
47
26
48
- func (c * client ) StartCPUProfiler (ctx context.Context , options ... rpc.Option ) error {
49
- return c .requester .SendRequest (ctx , "admin.startCPUProfiler" , struct {}{}, & api.EmptyReply {}, options ... )
27
+ func (c * Client ) StartCPUProfiler (ctx context.Context , options ... rpc.Option ) error {
28
+ return c .Requester .SendRequest (ctx , "admin.startCPUProfiler" , struct {}{}, & api.EmptyReply {}, options ... )
50
29
}
51
30
52
- func (c * client ) StopCPUProfiler (ctx context.Context , options ... rpc.Option ) error {
53
- return c .requester .SendRequest (ctx , "admin.stopCPUProfiler" , struct {}{}, & api.EmptyReply {}, options ... )
31
+ func (c * Client ) StopCPUProfiler (ctx context.Context , options ... rpc.Option ) error {
32
+ return c .Requester .SendRequest (ctx , "admin.stopCPUProfiler" , struct {}{}, & api.EmptyReply {}, options ... )
54
33
}
55
34
56
- func (c * client ) MemoryProfile (ctx context.Context , options ... rpc.Option ) error {
57
- return c .requester .SendRequest (ctx , "admin.memoryProfile" , struct {}{}, & api.EmptyReply {}, options ... )
35
+ func (c * Client ) MemoryProfile (ctx context.Context , options ... rpc.Option ) error {
36
+ return c .Requester .SendRequest (ctx , "admin.memoryProfile" , struct {}{}, & api.EmptyReply {}, options ... )
58
37
}
59
38
60
- func (c * client ) LockProfile (ctx context.Context , options ... rpc.Option ) error {
61
- return c .requester .SendRequest (ctx , "admin.lockProfile" , struct {}{}, & api.EmptyReply {}, options ... )
39
+ func (c * Client ) LockProfile (ctx context.Context , options ... rpc.Option ) error {
40
+ return c .Requester .SendRequest (ctx , "admin.lockProfile" , struct {}{}, & api.EmptyReply {}, options ... )
62
41
}
63
42
64
- func (c * client ) Alias (ctx context.Context , endpoint , alias string , options ... rpc.Option ) error {
65
- return c .requester .SendRequest (ctx , "admin.alias" , & AliasArgs {
43
+ func (c * Client ) Alias (ctx context.Context , endpoint , alias string , options ... rpc.Option ) error {
44
+ return c .Requester .SendRequest (ctx , "admin.alias" , & AliasArgs {
66
45
Endpoint : endpoint ,
67
46
Alias : alias ,
68
47
}, & api.EmptyReply {}, options ... )
69
48
}
70
49
71
- func (c * client ) AliasChain (ctx context.Context , chain , alias string , options ... rpc.Option ) error {
72
- return c .requester .SendRequest (ctx , "admin.aliasChain" , & AliasChainArgs {
50
+ func (c * Client ) AliasChain (ctx context.Context , chain , alias string , options ... rpc.Option ) error {
51
+ return c .Requester .SendRequest (ctx , "admin.aliasChain" , & AliasChainArgs {
73
52
Chain : chain ,
74
53
Alias : alias ,
75
54
}, & api.EmptyReply {}, options ... )
76
55
}
77
56
78
- func (c * client ) GetChainAliases (ctx context.Context , chain string , options ... rpc.Option ) ([]string , error ) {
57
+ func (c * Client ) GetChainAliases (ctx context.Context , chain string , options ... rpc.Option ) ([]string , error ) {
79
58
res := & GetChainAliasesReply {}
80
- err := c .requester .SendRequest (ctx , "admin.getChainAliases" , & GetChainAliasesArgs {
59
+ err := c .Requester .SendRequest (ctx , "admin.getChainAliases" , & GetChainAliasesArgs {
81
60
Chain : chain ,
82
61
}, res , options ... )
83
62
return res .Aliases , err
84
63
}
85
64
86
- func (c * client ) Stacktrace (ctx context.Context , options ... rpc.Option ) error {
87
- return c .requester .SendRequest (ctx , "admin.stacktrace" , struct {}{}, & api.EmptyReply {}, options ... )
65
+ func (c * Client ) Stacktrace (ctx context.Context , options ... rpc.Option ) error {
66
+ return c .Requester .SendRequest (ctx , "admin.stacktrace" , struct {}{}, & api.EmptyReply {}, options ... )
88
67
}
89
68
90
- func (c * client ) LoadVMs (ctx context.Context , options ... rpc.Option ) (map [ids.ID ][]string , map [ids.ID ]string , error ) {
69
+ func (c * Client ) LoadVMs (ctx context.Context , options ... rpc.Option ) (map [ids.ID ][]string , map [ids.ID ]string , error ) {
91
70
res := & LoadVMsReply {}
92
- err := c .requester .SendRequest (ctx , "admin.loadVMs" , struct {}{}, res , options ... )
71
+ err := c .Requester .SendRequest (ctx , "admin.loadVMs" , struct {}{}, res , options ... )
93
72
return res .NewVMs , res .FailedVMs , err
94
73
}
95
74
96
- func (c * client ) SetLoggerLevel (
75
+ func (c * Client ) SetLoggerLevel (
97
76
ctx context.Context ,
98
77
loggerName ,
99
78
logLevel ,
@@ -118,40 +97,40 @@ func (c *client) SetLoggerLevel(
118
97
}
119
98
}
120
99
res := & LoggerLevelReply {}
121
- err = c .requester .SendRequest (ctx , "admin.setLoggerLevel" , & SetLoggerLevelArgs {
100
+ err = c .Requester .SendRequest (ctx , "admin.setLoggerLevel" , & SetLoggerLevelArgs {
122
101
LoggerName : loggerName ,
123
102
LogLevel : & logLevelArg ,
124
103
DisplayLevel : & displayLevelArg ,
125
104
}, res , options ... )
126
105
return res .LoggerLevels , err
127
106
}
128
107
129
- func (c * client ) GetLoggerLevel (
108
+ func (c * Client ) GetLoggerLevel (
130
109
ctx context.Context ,
131
110
loggerName string ,
132
111
options ... rpc.Option ,
133
112
) (map [string ]LogAndDisplayLevels , error ) {
134
113
res := & LoggerLevelReply {}
135
- err := c .requester .SendRequest (ctx , "admin.getLoggerLevel" , & GetLoggerLevelArgs {
114
+ err := c .Requester .SendRequest (ctx , "admin.getLoggerLevel" , & GetLoggerLevelArgs {
136
115
LoggerName : loggerName ,
137
116
}, res , options ... )
138
117
return res .LoggerLevels , err
139
118
}
140
119
141
- func (c * client ) GetConfig (ctx context.Context , options ... rpc.Option ) (interface {}, error ) {
120
+ func (c * Client ) GetConfig (ctx context.Context , options ... rpc.Option ) (interface {}, error ) {
142
121
var res interface {}
143
- err := c .requester .SendRequest (ctx , "admin.getConfig" , struct {}{}, & res , options ... )
122
+ err := c .Requester .SendRequest (ctx , "admin.getConfig" , struct {}{}, & res , options ... )
144
123
return res , err
145
124
}
146
125
147
- func (c * client ) DBGet (ctx context.Context , key []byte , options ... rpc.Option ) ([]byte , error ) {
126
+ func (c * Client ) DBGet (ctx context.Context , key []byte , options ... rpc.Option ) ([]byte , error ) {
148
127
keyStr , err := formatting .Encode (formatting .HexNC , key )
149
128
if err != nil {
150
129
return nil , err
151
130
}
152
131
153
132
res := & DBGetReply {}
154
- err = c .requester .SendRequest (ctx , "admin.dbGet" , & DBGetArgs {
133
+ err = c .Requester .SendRequest (ctx , "admin.dbGet" , & DBGetArgs {
155
134
Key : keyStr ,
156
135
}, res , options ... )
157
136
if err != nil {
0 commit comments