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

refactor: renterd account reset drift moved to worker #707

Merged
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
7 changes: 7 additions & 0 deletions .changeset/cold-trees-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

The account reset drift API was moved from bus to worker. Closes https://github.com/SiaFoundation/web/issues/704
9 changes: 0 additions & 9 deletions libs/renterd-js/src/bus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse,
AlertsDismissParams,
AlertsDismissPayload,
AlertsDismissResponse,
Expand Down Expand Up @@ -212,7 +209,6 @@ import {
WalletUtxoParams,
WalletUtxoPayload,
WalletUtxoResponse,
busAccountIdResetdriftRoute,
busAlertsDismissRoute,
busAlertsRoute,
busBucketNamePolicyRoute,
Expand Down Expand Up @@ -419,11 +415,6 @@ export function Bus({ api, password }: { api: string; password?: string }) {
HostResetLostSectorCountPayload,
HostResetLostSectorCountResponse
>(axios, 'post', busHostPublicKeyResetlostsectorsRoute),
accountResetDrift: buildRequestHandler<
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse
>(axios, 'post', busAccountIdResetdriftRoute),
contracts: buildRequestHandler<
ContractsParams,
ContractsPayload,
Expand Down
9 changes: 9 additions & 0 deletions libs/renterd-js/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse,
MultipartUploadPartParams,
MultipartUploadPartPayload,
MultipartUploadPartResponse,
Expand All @@ -14,6 +17,7 @@ import {
WorkerStateParams,
WorkerStatePayload,
WorkerStateResponse,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerRhpScanRoute,
Expand Down Expand Up @@ -66,5 +70,10 @@ export function Worker({ api, password }: { api: string; password?: string }) {
RhpScanPayload,
RhpScanResponse
>(axios, 'post', workerRhpScanRoute),
accountResetDrift: buildRequestHandler<
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse
>(axios, 'post', workerAccountIdResetdriftRoute),
}
}
19 changes: 0 additions & 19 deletions libs/renterd-react/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import {
getTestnetZenBlockHeight,
} from '@siafoundation/units'
import {
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse,
AlertsDismissParams,
AlertsDismissPayload,
AlertsDismissResponse,
Expand Down Expand Up @@ -185,7 +182,6 @@ import {
WalletTransactionsResponse,
WalletUtxoParams,
WalletUtxoResponse,
busAccountIdResetdriftRoute,
busBucketRoute,
busBucketNamePolicyRoute,
busBucketNameRoute,
Expand Down Expand Up @@ -582,21 +578,6 @@ export function useHostResetLostSectorCount(
})
}

// accounts

export function useAccountResetDrift(
args?: HookArgsCallback<
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse
>
) {
return usePostFunc({
...args,
route: busAccountIdResetdriftRoute,
})
}

// contracts

export function useContracts(
Expand Down
19 changes: 19 additions & 0 deletions libs/renterd-react/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
useGetSwr,
} from '@siafoundation/react-core'
import {
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse,
AutopilotHost,
Host,
MultipartUploadPartParams,
Expand All @@ -27,6 +30,7 @@ import {
autopilotHostsRoute,
busObjectsRoute,
busSearchHostsRoute,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerRhpScanRoute,
Expand Down Expand Up @@ -170,3 +174,18 @@ export function useRhpScan(
}
)
}

// accounts

export function useAccountResetDrift(
args?: HookArgsCallback<
AccountResetDriftParams,
AccountResetDriftPayload,
AccountResetDriftResponse
>
) {
return usePostFunc({
...args,
route: workerAccountIdResetdriftRoute,
})
}
7 changes: 0 additions & 7 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const busHostsBlocklistRoute = '/bus/hosts/blocklist'
export const busHostsAllowlistRoute = '/bus/hosts/allowlist'
export const busHostPublicKeyResetlostsectorsRoute =
'/bus/host/:publicKey/resetlostsectors'
export const busAccountIdResetdriftRoute = '/bus/account/:id/resetdrift'
export const busContractsRoute = '/bus/contracts'
export const busContractIdAcquireRoute = '/bus/contract/:id/acquire'
export const busContractIdReleaseRoute = '/bus/contract/:id/release'
Expand Down Expand Up @@ -285,12 +284,6 @@ export type HostResetLostSectorCountParams = {
export type HostResetLostSectorCountPayload = void
export type HostResetLostSectorCountResponse = void

// accounts

export type AccountResetDriftParams = { id: string }
export type AccountResetDriftPayload = void
export type AccountResetDriftResponse = void

// contracts

export type ContractsParams = void
Expand Down
13 changes: 13 additions & 0 deletions libs/renterd-types/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const workerStateRoute = '/worker/state'
export const workerObjectsKeyRoute = '/worker/objects/:key'
export const workerMultipartKeyRoute = '/worker/multipart/:key'
export const workerRhpScanRoute = '/worker/rhp/scan'
export const workerAccountIdResetdriftRoute = '/worker/account/:id/resetdrift'

// state

Expand All @@ -14,6 +15,8 @@ export type WorkerStateResponse = BusStateResponse & {
id: string
}

// objects

export type ObjectDownloadParams = { key: string; bucket: string }
export type ObjectDownloadPayload = void
export type ObjectDownloadResponse = Blob
Expand All @@ -28,6 +31,8 @@ export type ObjectUploadPayload =
| Record<string, unknown>
export type ObjectUploadResponse = void

// multipart

export type MultipartUploadPartParams = {
key: string
uploadid: string
Expand All @@ -41,6 +46,8 @@ export type MultipartUploadPartParams = {
export type MultipartUploadPartPayload = Blob | Buffer | ArrayBuffer | string
export type MultipartUploadPartResponse = void

// rhp

export type RhpScanParams = void
export type RhpScanPayload = {
hostKey: string
Expand All @@ -52,3 +59,9 @@ export type RhpScanResponse = {
scanError?: string
settings?: HostSettings
}

// accounts

export type AccountResetDriftParams = { id: string }
export type AccountResetDriftPayload = void
export type AccountResetDriftResponse = void
Loading