Skip to content

Commit

Permalink
worker: remove registry
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Dec 4, 2023
1 parent f37012b commit 9e80235
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 69 deletions.
9 changes: 0 additions & 9 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,6 @@ type (
AccountKey types.PrivateKey `json:"accountKey"`
}

// RHPRegistryReadRequest is the request type for the /rhp/registry/read
// endpoint.
RHPRegistryReadRequest struct {
HostKey types.PublicKey `json:"hostKey"`
SiamuxAddr string `json:"siamuxAddr"`
RegistryKey rhpv3.RegistryKey `json:"registryKey"`
Payment rhpv3.PayByEphemeralAccountRequest `json:"payment"`
}

// RHPRegistryUpdateRequest is the request type for the /rhp/registry/update
// endpoint.
RHPRegistryUpdateRequest struct {
Expand Down
24 changes: 0 additions & 24 deletions worker/client/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.sia.tech/renterd/hostdb"

rhpv2 "go.sia.tech/core/rhp/v2"
rhpv3 "go.sia.tech/core/rhp/v3"
)

// RHPBroadcast broadcasts the latest revision for a contract.
Expand Down Expand Up @@ -74,18 +73,6 @@ func (c *Client) RHPPruneContract(ctx context.Context, contractID types.FileCont
return
}

// RHPReadRegistry reads a registry value.
func (c *Client) RHPReadRegistry(ctx context.Context, hostKey types.PublicKey, siamuxAddr string, key rhpv3.RegistryKey, payment rhpv3.PayByEphemeralAccountRequest) (resp rhpv3.RegistryValue, err error) {
req := api.RHPRegistryReadRequest{
HostKey: hostKey,
SiamuxAddr: siamuxAddr,
RegistryKey: key,
Payment: payment,
}
err = c.c.WithContext(ctx).POST("/rhp/registry/read", req, &resp)
return
}

// RHPRenew renews an existing contract with a host.
func (c *Client) RHPRenew(ctx context.Context, contractID types.FileContractID, endHeight uint64, hostKey types.PublicKey, siamuxAddr string, hostAddress, renterAddress types.Address, renterFunds, newCollateral types.Currency, windowSize uint64) (rhpv2.ContractRevision, []types.Transaction, error) {
req := api.RHPRenewRequest{
Expand Down Expand Up @@ -125,14 +112,3 @@ func (c *Client) RHPSync(ctx context.Context, contractID types.FileContractID, h
err = c.c.WithContext(ctx).POST("/rhp/sync", req, nil)
return
}

// RHPUpdateRegistry updates a registry value.
func (c *Client) RHPUpdateRegistry(ctx context.Context, hostKey types.PublicKey, key rhpv3.RegistryKey, value rhpv3.RegistryValue) (err error) {
req := api.RHPRegistryUpdateRequest{
HostKey: hostKey,
RegistryKey: key,
RegistryValue: value,
}
err = c.c.WithContext(ctx).POST("/rhp/registry/update", req, nil)
return
}
36 changes: 0 additions & 36 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,40 +799,6 @@ func (w *worker) rhpFundHandler(jc jape.Context) {
}))
}

func (w *worker) rhpRegistryReadHandler(jc jape.Context) {
var rrrr api.RHPRegistryReadRequest
if jc.Decode(&rrrr) != nil {
return
}
var value rhpv3.RegistryValue
err := w.transportPoolV3.withTransportV3(jc.Request.Context(), rrrr.HostKey, rrrr.SiamuxAddr, func(ctx context.Context, t *transportV3) (err error) {
value, err = RPCReadRegistry(ctx, t, &rrrr.Payment, rrrr.RegistryKey)
return
})
if jc.Check("couldn't read registry", err) != nil {
return
}
jc.Encode(value)
}

func (w *worker) rhpRegistryUpdateHandler(jc jape.Context) {
var rrur api.RHPRegistryUpdateRequest
if jc.Decode(&rrur) != nil {
return
}
var pt rhpv3.HostPriceTable // TODO
rc := pt.UpdateRegistryCost() // TODO: handle refund
cost, _ := rc.Total()
// TODO: refactor to a w.RegistryUpdate method that calls host.RegistryUpdate.
payment := preparePayment(w.accounts.deriveAccountKey(rrur.HostKey), cost, pt.HostBlockHeight)
err := w.transportPoolV3.withTransportV3(jc.Request.Context(), rrur.HostKey, rrur.SiamuxAddr, func(ctx context.Context, t *transportV3) (err error) {
return RPCUpdateRegistry(ctx, t, &payment, rrur.RegistryKey, rrur.RegistryValue)
})
if jc.Check("couldn't update registry", err) != nil {
return
}
}

func (w *worker) rhpSyncHandler(jc jape.Context) {
ctx := jc.Request.Context()

Expand Down Expand Up @@ -1468,8 +1434,6 @@ func (w *worker) Handler() http.Handler {
"POST /rhp/fund": w.rhpFundHandler,
"POST /rhp/sync": w.rhpSyncHandler,
"POST /rhp/pricetable": w.rhpPriceTableHandler,
"POST /rhp/registry/read": w.rhpRegistryReadHandler,
"POST /rhp/registry/update": w.rhpRegistryUpdateHandler,

"GET /stats/downloads": w.downloadsStatsHandlerGET,
"GET /stats/uploads": w.uploadsStatsHandlerGET,
Expand Down

0 comments on commit 9e80235

Please sign in to comment.