@@ -14,86 +14,65 @@ import (
1414 "github.com/ava-labs/avalanchego/utils/rpc"
1515)
1616
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
3419}
3520
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 (
4423 uri + "/ext/admin" ,
4524 )}
4625}
4726
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 ... )
5029}
5130
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 ... )
5433}
5534
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 ... )
5837}
5938
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 ... )
6241}
6342
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 {
6645 Endpoint : endpoint ,
6746 Alias : alias ,
6847 }, & api.EmptyReply {}, options ... )
6948}
7049
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 {
7352 Chain : chain ,
7453 Alias : alias ,
7554 }, & api.EmptyReply {}, options ... )
7655}
7756
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 ) {
7958 res := & GetChainAliasesReply {}
80- err := c .requester .SendRequest (ctx , "admin.getChainAliases" , & GetChainAliasesArgs {
59+ err := c .Requester .SendRequest (ctx , "admin.getChainAliases" , & GetChainAliasesArgs {
8160 Chain : chain ,
8261 }, res , options ... )
8362 return res .Aliases , err
8463}
8564
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 ... )
8867}
8968
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 ) {
9170 res := & LoadVMsReply {}
92- err := c .requester .SendRequest (ctx , "admin.loadVMs" , struct {}{}, res , options ... )
71+ err := c .Requester .SendRequest (ctx , "admin.loadVMs" , struct {}{}, res , options ... )
9372 return res .NewVMs , res .FailedVMs , err
9473}
9574
96- func (c * client ) SetLoggerLevel (
75+ func (c * Client ) SetLoggerLevel (
9776 ctx context.Context ,
9877 loggerName ,
9978 logLevel ,
@@ -118,40 +97,40 @@ func (c *client) SetLoggerLevel(
11897 }
11998 }
12099 res := & LoggerLevelReply {}
121- err = c .requester .SendRequest (ctx , "admin.setLoggerLevel" , & SetLoggerLevelArgs {
100+ err = c .Requester .SendRequest (ctx , "admin.setLoggerLevel" , & SetLoggerLevelArgs {
122101 LoggerName : loggerName ,
123102 LogLevel : & logLevelArg ,
124103 DisplayLevel : & displayLevelArg ,
125104 }, res , options ... )
126105 return res .LoggerLevels , err
127106}
128107
129- func (c * client ) GetLoggerLevel (
108+ func (c * Client ) GetLoggerLevel (
130109 ctx context.Context ,
131110 loggerName string ,
132111 options ... rpc.Option ,
133112) (map [string ]LogAndDisplayLevels , error ) {
134113 res := & LoggerLevelReply {}
135- err := c .requester .SendRequest (ctx , "admin.getLoggerLevel" , & GetLoggerLevelArgs {
114+ err := c .Requester .SendRequest (ctx , "admin.getLoggerLevel" , & GetLoggerLevelArgs {
136115 LoggerName : loggerName ,
137116 }, res , options ... )
138117 return res .LoggerLevels , err
139118}
140119
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 ) {
142121 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 ... )
144123 return res , err
145124}
146125
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 ) {
148127 keyStr , err := formatting .Encode (formatting .HexNC , key )
149128 if err != nil {
150129 return nil , err
151130 }
152131
153132 res := & DBGetReply {}
154- err = c .requester .SendRequest (ctx , "admin.dbGet" , & DBGetArgs {
133+ err = c .Requester .SendRequest (ctx , "admin.dbGet" , & DBGetArgs {
155134 Key : keyStr ,
156135 }, res , options ... )
157136 if err != nil {
0 commit comments