Skip to content

Commit

Permalink
feat: add datalayer service in client
Browse files Browse the repository at this point in the history
  • Loading branch information
blackhorseya committed Jun 14, 2023
1 parent 6b4cfb6 commit b59c299
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Client struct {
FarmerService *FarmerService
HarvesterService *HarvesterService
CrawlerService *CrawlerService
DataLayerService *DataLayerService

websocketHandlers []rpcinterface.WebsocketResponseHandler
}
Expand Down Expand Up @@ -67,6 +68,7 @@ func NewClient(connectionMode ConnectionMode, configOption rpcinterface.ConfigOp
c.FarmerService = &FarmerService{client: c}
c.HarvesterService = &HarvesterService{client: c}
c.CrawlerService = &CrawlerService{client: c}
c.DataLayerService = &DataLayerService{client: c}

return c, nil
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/rpc/datalayer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package rpc

import (
"net/http"

"github.com/chia-network/go-chia-libs/pkg/rpcinterface"
)

// DataLayerService encapsulates data layer RPC methods
type DataLayerService struct {
client *Client
}

// NewRequest returns a new request specific to the wallet service
func (s *DataLayerService) NewRequest(rpcEndpoint rpcinterface.Endpoint, opt interface{}) (*rpcinterface.Request, error) {
return s.client.NewRequest(rpcinterface.ServiceFullNode, rpcEndpoint, opt)
}

// Do is just a shortcut to the client's Do method
func (s *DataLayerService) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error) {
return s.client.Do(req, v)
}

0 comments on commit b59c299

Please sign in to comment.