Skip to content

Commit

Permalink
Refactor worker to derive its own account for each host (#1464)
Browse files Browse the repository at this point in the history
Closes #1462
  • Loading branch information
ChrisSchinnerl committed Aug 28, 2024
2 parents 225c369 + 6a46895 commit b9ec530
Show file tree
Hide file tree
Showing 37 changed files with 1,187 additions and 1,630 deletions.
4 changes: 4 additions & 0 deletions api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type (
// an account and the balance reported by a host.
Drift *big.Int `json:"drift"`

// Owner is the owner of the account which is responsible for funding
// it.
Owner string `json:"owner"`

// RequiresSync indicates whether an account needs to be synced with the
// host before it can be used again.
RequiresSync bool `json:"requiresSync"`
Expand Down
4 changes: 4 additions & 0 deletions api/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ type (
)

type (
AccountsSaveRequest struct {
Accounts []Account `json:"accounts"`
}

// BusStateResponse is the response type for the /bus/state endpoint.
BusStateResponse struct {
StartTime TimeRFC3339 `json:"startTime"`
Expand Down
8 changes: 0 additions & 8 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ type (
TransactionSet []types.Transaction `json:"transactionSet"`
}

// RHPFundRequest is the request type for the /rhp/fund endpoint.
RHPFundRequest struct {
ContractID types.FileContractID `json:"contractID"`
HostKey types.PublicKey `json:"hostKey"`
SiamuxAddr string `json:"siamuxAddr"`
Balance types.Currency `json:"balance"`
}

// RHPPruneContractRequest is the request type for the /rhp/contract/:id/prune
// endpoint.
RHPPruneContractRequest struct {
Expand Down
291 changes: 0 additions & 291 deletions autopilot/accounts.go

This file was deleted.

23 changes: 0 additions & 23 deletions autopilot/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import (
"fmt"
"time"

rhpv3 "go.sia.tech/core/rhp/v3"
"go.sia.tech/core/types"
"go.sia.tech/renterd/alerts"
"go.sia.tech/renterd/api"
"go.sia.tech/renterd/object"
)

var (
alertAccountRefillID = alerts.RandomAlertID() // constant until restarted
alertHealthRefreshID = alerts.RandomAlertID() // constant until restarted
alertLowBalanceID = alerts.RandomAlertID() // constant until restarted
alertMigrationID = alerts.RandomAlertID() // constant until restarted
Expand Down Expand Up @@ -54,26 +51,6 @@ func newAccountLowBalanceAlert(address types.Address, balance, allowance types.C
}
}

func newAccountRefillAlert(id rhpv3.Account, contract api.ContractMetadata, err refillError) alerts.Alert {
data := map[string]interface{}{
"error": err.Error(),
"accountID": id.String(),
"contractID": contract.ID.String(),
"hostKey": contract.HostKey.String(),
}
for i := 0; i < len(err.keysAndValues); i += 2 {
data[fmt.Sprint(err.keysAndValues[i])] = err.keysAndValues[i+1]
}

return alerts.Alert{
ID: alerts.IDForAccount(alertAccountRefillID, id),
Severity: alerts.SeverityError,
Message: "Ephemeral account refill failed",
Data: data,
Timestamp: time.Now(),
}
}

func newContractPruningFailedAlert(hk types.PublicKey, version, release string, fcid types.FileContractID, err error) alerts.Alert {
return alerts.Alert{
ID: alerts.IDForContract(alertPruningID, fcid),
Expand Down
Loading

0 comments on commit b9ec530

Please sign in to comment.