Skip to content

Commit

Permalink
Add get_version endpoints to all services (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Jul 31, 2024
1 parent f1c52af commit f278718
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/rpc/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ func (s *CrawlerService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwor
return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *CrawlerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// GetPeerCountsResponse Response for get_get_peer_counts on crawler
type GetPeerCountsResponse struct {
Response
Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ func (s *DaemonService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork
return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *DaemonService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// GetKeysOptions configures how keys are returned in get_keys
type GetKeysOptions struct {
IncludeSecrets bool `json:"include_secrets"`
Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/datalayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ func (s *DataLayerService) NewRequest(rpcEndpoint rpcinterface.Endpoint, opt int
func (s *DataLayerService) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error) {
return s.client.Do(req, v)
}

// GetVersion returns the application version for the service
func (s *DataLayerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}
16 changes: 16 additions & 0 deletions pkg/rpc/farmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ func (s *FarmerService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork
return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *FarmerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// FarmerGetHarvestersOptions optoins for get_harvesters endpoint. Currently, accepts no options
type FarmerGetHarvestersOptions struct{}

Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ type GetBlockchainStateResponse struct {
BlockchainState mo.Option[types.BlockchainState] `json:"blockchain_state,omitempty"`
}

// GetVersion returns the application version for the service
func (s *FullNodeService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// GetBlockchainState returns blockchain state
func (s *FullNodeService) GetBlockchainState() (*GetBlockchainStateResponse, *http.Response, error) {
request, err := s.NewRequest("get_blockchain_state", nil)
Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ func (s *HarvesterService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetw
return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *HarvesterService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// HarvesterGetPlotsResponse get_plots response format
type HarvesterGetPlotsResponse struct {
Response
Expand Down
9 changes: 9 additions & 0 deletions pkg/rpc/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ type GetNetworkInfoResponse struct {
NetworkName mo.Option[string] `json:"network_name"`
NetworkPrefix mo.Option[string] `json:"network_prefix"`
}

// GetVersionOptions options for the get_version rpc calls
type GetVersionOptions struct{}

// GetVersionResponse is the response of get_version from all RPC services
type GetVersionResponse struct {
Response
Version string `json:"version"`
}
16 changes: 16 additions & 0 deletions pkg/rpc/timelord.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ func (s *TimelordService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwo

return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *TimelordService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}
16 changes: 16 additions & 0 deletions pkg/rpc/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ func (s *WalletService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork
return r, resp, nil
}

// GetVersion returns the application version for the service
func (s *WalletService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) {
request, err := s.NewRequest("get_version", opts)
if err != nil {
return nil, nil, err
}

r := &GetVersionResponse{}
resp, err := s.Do(request, r)
if err != nil {
return nil, resp, err
}

return r, resp, nil
}

// GetPublicKeysResponse response from get_public_keys
type GetPublicKeysResponse struct {
Response
Expand Down

0 comments on commit f278718

Please sign in to comment.