-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Chia-Network/harvester-get-plots
Harvester get plots
- Loading branch information
Showing
8 changed files
with
121 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package rpc | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/chia-network/go-chia-libs/pkg/rpcinterface" | ||
"github.com/chia-network/go-chia-libs/pkg/types" | ||
) | ||
|
||
// HarvesterService encapsulates harvester RPC methods | ||
type HarvesterService struct { | ||
client *Client | ||
} | ||
|
||
// NewRequest returns a new request specific to the wallet service | ||
func (s *HarvesterService) NewRequest(rpcEndpoint rpcinterface.Endpoint, opt interface{}) (*rpcinterface.Request, error) { | ||
return s.client.NewRequest(rpcinterface.ServiceHarvester, rpcEndpoint, opt) | ||
} | ||
|
||
// Do is just a shortcut to the client's Do method | ||
func (s *HarvesterService) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error) { | ||
return s.client.Do(req, v) | ||
} | ||
|
||
// HarvesterGetPlotsResponse get_plots response format | ||
type HarvesterGetPlotsResponse struct { | ||
Success bool `json:"success"` | ||
Plots []*types.PlotInfo `json:"plots"` | ||
FailedToOpenFilenames []string `json:"failed_to_open_filenames"` | ||
NotFoundFilenames []string `json:"not_found_filenames"` | ||
} | ||
|
||
// GetPlots returns connections | ||
func (s *HarvesterService) GetPlots() (*HarvesterGetPlotsResponse, *http.Response, error) { | ||
request, err := s.NewRequest("get_plots", nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
p := &HarvesterGetPlotsResponse{} | ||
resp, err := s.Do(request, p) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return p, resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters