From 22af725c625c680bf69cf27a330381e1e90e03ad Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Thu, 1 Aug 2024 13:35:14 -0500 Subject: [PATCH] Add get_subscriptions endpoint + fix config parsing --- pkg/config/config.go | 18 +++++++++--------- pkg/rpc/datalayer.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6dacbf3..aec78db 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -194,15 +194,15 @@ type PoolConfig struct { // FarmerConfig farmer configuration section type FarmerConfig struct { - FullNodePeers []Peer `yaml:"full_node_peers"` - PoolPublicKeys []string `yaml:"pool_public_keys"` // @TODO test if the !!set notation parses correctly - XCHTargetAddress string `yaml:"xch_target_address,omitempty"` - StartRPCServer bool `yaml:"start_rpc_server"` - EnableProfiler bool `yaml:"enable_profiler"` - PoolShareThreshold uint32 `yaml:"pool_share_threshold"` - Logging LoggingConfig `yaml:"logging"` - NetworkOverrides NetworkOverrides `yaml:"network_overrides"` - SelectedNetwork string `yaml:"selected_network"` + FullNodePeers []Peer `yaml:"full_node_peers"` + PoolPublicKeys map[string]string `yaml:"pool_public_keys"` + XCHTargetAddress string `yaml:"xch_target_address,omitempty"` + StartRPCServer bool `yaml:"start_rpc_server"` + EnableProfiler bool `yaml:"enable_profiler"` + PoolShareThreshold uint32 `yaml:"pool_share_threshold"` + Logging LoggingConfig `yaml:"logging"` + NetworkOverrides NetworkOverrides `yaml:"network_overrides"` + SelectedNetwork string `yaml:"selected_network"` PortConfig `yaml:",inline"` SSL SSLConfig `yaml:"ssl"` } diff --git a/pkg/rpc/datalayer.go b/pkg/rpc/datalayer.go index 588cd73..17df44c 100644 --- a/pkg/rpc/datalayer.go +++ b/pkg/rpc/datalayer.go @@ -36,3 +36,35 @@ func (s *DataLayerService) GetVersion(opts *GetVersionOptions) (*GetVersionRespo return r, resp, nil } + +// DatalayerGetSubscriptionsOptions options for get_subscriptions +type DatalayerGetSubscriptionsOptions struct{} + +// DatalayerGetSubscriptionsResponse response for get_subscriptions +type DatalayerGetSubscriptionsResponse struct { + Response + StoreIDs []string `json:"store_ids"` +} + +// GetSubscriptions is just an alias for Subscriptions, since the CLI command is get_subscriptions +// Makes this easier to find +func (s *DataLayerService) GetSubscriptions(opts *DatalayerGetSubscriptionsOptions) (*DatalayerGetSubscriptionsResponse, *http.Response, error) { + return s.Subscriptions(opts) +} + +// Subscriptions calls the subscriptions endpoint to list all subscriptions +func (s *DataLayerService) Subscriptions(opts *DatalayerGetSubscriptionsOptions) (*DatalayerGetSubscriptionsResponse, *http.Response, error) { + request, err := s.NewRequest("subscriptions", opts) + if err != nil { + return nil, nil, err + } + + r := &DatalayerGetSubscriptionsResponse{} + + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +}