Documentation
¶
Index ¶
- Variables
- func GougingCheckerFromContext(ctx context.Context, criticalMigration bool) (gouging.Checker, error)
- func WithGougingChecker(ctx context.Context, cs gouging.ConsensusState, gp api.GougingParams) context.Context
- type AccountStore
- type Bus
- type Client
- type ContractLocker
- type ContractSpendingRecorder
- type ContractStore
- type Host
- type HostErrorSet
- type HostManager
- type HostStore
- type Memory
- type MemoryManager
- type ObjectStore
- type SettingStore
- type Syncer
- type UploadOption
- func WithBlockHeight(bh uint64) UploadOption
- func WithContractSet(contractSet string) UploadOption
- func WithCustomEncryptionOffset(offset uint64) UploadOption
- func WithCustomKey(ec object.EncryptionKey) UploadOption
- func WithMimeType(mimeType string) UploadOption
- func WithObjectUserMetadata(metadata api.ObjectUserMetadata) UploadOption
- func WithPacking(packing bool) UploadOption
- func WithPartNumber(partNumber int) UploadOption
- func WithUploadID(uploadID string) UploadOption
- type Wallet
- type WebhookStore
- type Worker
- func (w *Worker) GetObject(ctx context.Context, bucket, path string, opts api.DownloadObjectOptions) (*api.GetObjectResponse, error)
- func (w *Worker) Handler() http.Handler
- func (w *Worker) HeadObject(ctx context.Context, bucket, path string, opts api.HeadObjectOptions) (*api.HeadObjectResponse, error)
- func (w *Worker) Host(hk types.PublicKey, fcid types.FileContractID, siamuxAddr string) Host
- func (w *Worker) Setup(ctx context.Context, apiURL, apiPassword string) error
- func (w *Worker) Shutdown(ctx context.Context) error
- func (w *Worker) UploadMultipartUploadPart(ctx context.Context, r io.Reader, bucket, path, uploadID string, ...) (*api.UploadMultipartUploadPartResponse, error)
- func (w *Worker) UploadObject(ctx context.Context, r io.Reader, bucket, path string, ...) (*api.UploadObjectResponse, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrShuttingDown = errors.New("worker is shutting down")
)
Functions ¶
func WithGougingChecker ¶
func WithGougingChecker(ctx context.Context, cs gouging.ConsensusState, gp api.GougingParams) context.Context
Types ¶
type AccountStore ¶
type AccountStore interface { Accounts(ctx context.Context) ([]api.Account, error) AddBalance(ctx context.Context, id rhpv3.Account, hk types.PublicKey, amt *big.Int) error LockAccount(ctx context.Context, id rhpv3.Account, hostKey types.PublicKey, exclusive bool, duration time.Duration) (api.Account, uint64, error) UnlockAccount(ctx context.Context, id rhpv3.Account, lockID uint64) error SetBalance(ctx context.Context, id rhpv3.Account, hk types.PublicKey, amt *big.Int) error ScheduleSync(ctx context.Context, id rhpv3.Account, hk types.PublicKey) error }
An AccountStore manages ephemaral accounts state.
type Bus ¶
type Bus interface { s3.Bus alerts.Alerter gouging.ConsensusState webhooks.Broadcaster AccountStore ContractLocker ContractStore HostStore ObjectStore SettingStore WebhookStore Syncer Wallet }
type ContractLocker ¶
type ContractLocker interface { AcquireContract(ctx context.Context, fcid types.FileContractID, priority int, d time.Duration) (lockID uint64, err error) KeepaliveContract(ctx context.Context, fcid types.FileContractID, lockID uint64, d time.Duration) (err error) ReleaseContract(ctx context.Context, fcid types.FileContractID, lockID uint64) (err error) }
type ContractSpendingRecorder ¶
type ContractSpendingRecorder interface { Record(rev types.FileContractRevision, cs api.ContractSpending) Stop(context.Context) }
type ContractStore ¶ added in v1.0.2
type ContractStore interface { Contract(ctx context.Context, id types.FileContractID) (api.ContractMetadata, error) ContractSize(ctx context.Context, id types.FileContractID) (api.ContractSize, error) ContractRoots(ctx context.Context, id types.FileContractID) ([]types.Hash256, []types.Hash256, error) Contracts(ctx context.Context, opts api.ContractsOpts) ([]api.ContractMetadata, error) RenewedContract(ctx context.Context, renewedFrom types.FileContractID) (api.ContractMetadata, error) }
type Host ¶ added in v0.7.0
type Host interface { PublicKey() types.PublicKey DownloadSector(ctx context.Context, w io.Writer, root types.Hash256, offset, length uint32, overpay bool) error UploadSector(ctx context.Context, sectorRoot types.Hash256, sector *[rhpv2.SectorSize]byte, rev types.FileContractRevision) error PriceTable(ctx context.Context, rev *types.FileContractRevision) (api.HostPriceTable, types.Currency, error) PriceTableUnpaid(ctx context.Context) (hpt api.HostPriceTable, err error) FetchRevision(ctx context.Context, fetchTimeout time.Duration) (types.FileContractRevision, error) FundAccount(ctx context.Context, balance types.Currency, rev *types.FileContractRevision) error SyncAccount(ctx context.Context, rev *types.FileContractRevision) error RenewContract(ctx context.Context, rrr api.RHPRenewRequest) (_ rhpv2.ContractRevision, _ []types.Transaction, _, _ types.Currency, err error) }
type HostErrorSet ¶
A HostErrorSet is a collection of errors from various hosts.
func (HostErrorSet) NumGouging ¶ added in v0.7.0
func (hes HostErrorSet) NumGouging() (n int)
NumGouging returns numbers of host that errored out due to price gouging.
type HostManager ¶ added in v0.7.0
type HostStore ¶ added in v1.0.3
type HostStore interface { RecordHostScans(ctx context.Context, scans []api.HostScan) error RecordPriceTables(ctx context.Context, priceTableUpdate []api.HostPriceTableUpdate) error RecordContractSpending(ctx context.Context, records []api.ContractSpendingRecord) error Host(ctx context.Context, hostKey types.PublicKey) (api.Host, error) }
type MemoryManager ¶ added in v0.7.0
type MemoryManager interface { Status() api.MemoryStatus AcquireMemory(ctx context.Context, amt uint64) Memory Limit(amt uint64) (MemoryManager, error) }
MemoryManager helps regulate processes that use a lot of memory. Such as uploads and downloads.
type ObjectStore ¶ added in v0.7.0
type ObjectStore interface { // NOTE: used for download DeleteHostSector(ctx context.Context, hk types.PublicKey, root types.Hash256) error FetchPartialSlab(ctx context.Context, key object.EncryptionKey, offset, length uint32) ([]byte, error) Slab(ctx context.Context, key object.EncryptionKey) (object.Slab, error) // NOTE: used for upload AddObject(ctx context.Context, bucket, path, contractSet string, o object.Object, opts api.AddObjectOptions) error AddMultipartPart(ctx context.Context, bucket, path, contractSet, ETag, uploadID string, partNumber int, slices []object.SlabSlice) (err error) AddPartialSlab(ctx context.Context, data []byte, minShards, totalShards uint8, contractSet string) (slabs []object.SlabSlice, slabBufferMaxSizeSoftReached bool, err error) AddUploadingSector(ctx context.Context, uID api.UploadID, id types.FileContractID, root types.Hash256) error FinishUpload(ctx context.Context, uID api.UploadID) error MarkPackedSlabsUploaded(ctx context.Context, slabs []api.UploadedPackedSlab) error TrackUpload(ctx context.Context, uID api.UploadID) error UpdateSlab(ctx context.Context, s object.Slab, contractSet string) error // NOTE: used by worker Bucket(_ context.Context, bucket string) (api.Bucket, error) Object(ctx context.Context, bucket, path string, opts api.GetObjectOptions) (api.ObjectsResponse, error) DeleteObject(ctx context.Context, bucket, path string, opts api.DeleteObjectOptions) error MultipartUpload(ctx context.Context, uploadID string) (resp api.MultipartUpload, err error) PackedSlabsForUpload(ctx context.Context, lockingDuration time.Duration, minShards, totalShards uint8, set string, limit int) ([]api.PackedSlab, error) }
type SettingStore ¶ added in v1.0.6
type SettingStore interface { GougingParams(ctx context.Context) (api.GougingParams, error) UploadParams(ctx context.Context) (api.UploadParams, error) }
type UploadOption ¶ added in v0.6.0
type UploadOption func(*uploadParameters)
func WithBlockHeight ¶ added in v0.6.0
func WithBlockHeight(bh uint64) UploadOption
func WithContractSet ¶ added in v0.6.0
func WithContractSet(contractSet string) UploadOption
func WithCustomEncryptionOffset ¶ added in v0.6.0
func WithCustomEncryptionOffset(offset uint64) UploadOption
func WithCustomKey ¶ added in v0.6.0
func WithCustomKey(ec object.EncryptionKey) UploadOption
func WithMimeType ¶ added in v0.6.0
func WithMimeType(mimeType string) UploadOption
func WithObjectUserMetadata ¶ added in v1.0.3
func WithObjectUserMetadata(metadata api.ObjectUserMetadata) UploadOption
func WithPacking ¶ added in v0.6.0
func WithPacking(packing bool) UploadOption
func WithPartNumber ¶ added in v1.0.7
func WithPartNumber(partNumber int) UploadOption
func WithUploadID ¶ added in v1.0.7
func WithUploadID(uploadID string) UploadOption
type Wallet ¶ added in v1.0.6
type Wallet interface { WalletDiscard(ctx context.Context, txn types.Transaction) error WalletFund(ctx context.Context, txn *types.Transaction, amount types.Currency, useUnconfirmedTxns bool) ([]types.Hash256, []types.Transaction, error) WalletPrepareForm(ctx context.Context, renterAddress types.Address, renterKey types.PublicKey, renterFunds, hostCollateral types.Currency, hostKey types.PublicKey, hostSettings rhpv2.HostSettings, endHeight uint64) (txns []types.Transaction, err error) WalletPrepareRenew(ctx context.Context, revision types.FileContractRevision, hostAddress, renterAddress types.Address, renterKey types.PrivateKey, renterFunds, minNewCollateral, maxFundAmount types.Currency, pt rhpv3.HostPriceTable, endHeight, windowSize, expectedStorage uint64) (api.WalletPrepareRenewResponse, error) WalletSign(ctx context.Context, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error }
type WebhookStore ¶ added in v1.0.8
type Worker ¶ added in v1.1.0
type Worker struct {
// contains filtered or unexported fields
}
A worker talks to Sia hosts to perform contract and storage operations within a renterd system.
func (*Worker) GetObject ¶ added in v1.1.0
func (w *Worker) GetObject(ctx context.Context, bucket, path string, opts api.DownloadObjectOptions) (*api.GetObjectResponse, error)
func (*Worker) Handler ¶ added in v1.1.0
Handler returns an HTTP handler that serves the worker API.
func (*Worker) HeadObject ¶ added in v1.1.0
func (w *Worker) HeadObject(ctx context.Context, bucket, path string, opts api.HeadObjectOptions) (*api.HeadObjectResponse, error)
func (*Worker) UploadMultipartUploadPart ¶ added in v1.1.0
func (*Worker) UploadObject ¶ added in v1.1.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.