Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_version endpoints to all services #140

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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