Documentation
¶
Overview ¶
Package renter is responsible for uploading and downloading files on the sia network.
Index ¶
- Constants
- Variables
- func NewDownloadDestinationBuffer() *downloadDestinationBuffer
- type Renter
- func (r *Renter) ActiveHosts() []modules.HostDBEntry
- func (r *Renter) AllHosts() []modules.HostDBEntry
- func (r *Renter) BackupsOnHost(hostKey types.SiaPublicKey) ([]modules.UploadedBackup, error)
- func (r *Renter) CancelContract(id types.FileContractID) error
- func (r *Renter) ClearDownloadHistory(after, before time.Time) error
- func (r *Renter) Close() error
- func (r *Renter) ContractUtility(pk types.SiaPublicKey) (modules.ContractUtility, bool)
- func (r *Renter) Contracts() []modules.RenterContract
- func (r *Renter) CreateBackup(dst string, secret []byte) error
- func (r *Renter) CreateDir(siaPath modules.SiaPath) error
- func (r *Renter) CurrentPeriod() types.BlockHeight
- func (r *Renter) DeleteDir(siaPath modules.SiaPath) error
- func (r *Renter) DeleteFile(siaPath modules.SiaPath) error
- func (r *Renter) DirList(siaPath modules.SiaPath) ([]modules.DirectoryInfo, error)
- func (r *Renter) Download(p modules.RenterDownloadParameters) error
- func (r *Renter) DownloadAsync(p modules.RenterDownloadParameters, f func(error) error) (cancel func(), err error)
- func (r *Renter) DownloadBackup(dst string, name string) error
- func (r *Renter) DownloadHistory() []modules.DownloadInfo
- func (r *Renter) EstimateHostScore(e modules.HostDBEntry, a modules.Allowance) (modules.HostScoreBreakdown, error)
- func (r *Renter) File(siaPath modules.SiaPath) (modules.FileInfo, error)
- func (r *Renter) FileList(siaPath modules.SiaPath, recursive, cached bool) ([]modules.FileInfo, error)
- func (r *Renter) Filter() (modules.FilterMode, map[string]types.SiaPublicKey, error)
- func (r *Renter) Host(spk types.SiaPublicKey) (modules.HostDBEntry, bool)
- func (r *Renter) InitRecoveryScan() error
- func (r *Renter) InitialScanComplete() (bool, error)
- func (r *Renter) LoadBackup(src string, secret []byte) error
- func (r *Renter) OldContracts() []modules.RenterContract
- func (r *Renter) PeriodSpending() modules.ContractorSpending
- func (r *Renter) PriceEstimation(allowance modules.Allowance) (modules.RenterPriceEstimation, modules.Allowance, error)
- func (r *Renter) ProcessConsensusChange(cc modules.ConsensusChange)
- func (r *Renter) RecoverableContracts() []modules.RecoverableContract
- func (r *Renter) RecoveryScanStatus() (bool, types.BlockHeight)
- func (r *Renter) RefreshedContract(fcid types.FileContractID) bool
- func (r *Renter) RenameDir(oldPath, newPath modules.SiaPath) error
- func (r *Renter) RenameFile(currentName, newName modules.SiaPath) error
- func (r *Renter) ScoreBreakdown(e modules.HostDBEntry) (modules.HostScoreBreakdown, error)
- func (r *Renter) SetFileStuck(siaPath modules.SiaPath, stuck bool) error
- func (r *Renter) SetFileTrackingPath(siaPath modules.SiaPath, newPath string) error
- func (r *Renter) SetFilterMode(lm modules.FilterMode, hosts []types.SiaPublicKey) error
- func (r *Renter) SetIPViolationCheck(enabled bool)
- func (r *Renter) SetSettings(s modules.RenterSettings) error
- func (r *Renter) Settings() modules.RenterSettings
- func (r *Renter) Streamer(siaPath modules.SiaPath) (string, modules.Streamer, error)
- func (r *Renter) Upload(up modules.FileUploadParams) error
- func (r *Renter) UploadBackup(src, name string) error
- func (r *Renter) UploadStreamFromReader(up modules.FileUploadParams, reader io.Reader) error
- func (r *Renter) UploadedBackups() ([]modules.UploadedBackup, []types.SiaPublicKey, error)
- type SectionWriter
- type StreamShard
Constants ¶
const ( // DefaultMaxDownloadSpeed is set to zero to indicate no limit, the user // can set a custom MaxDownloadSpeed through the API DefaultMaxDownloadSpeed = 0 // DefaultMaxUploadSpeed is set to zero to indicate no limit, the user // can set a custom MaxUploadSpeed through the API DefaultMaxUploadSpeed = 0 )
Default bandwidth usage parameters.
const ( // PersistFilename is the filename to be used when persisting renter // information to a JSON file PersistFilename = "renter.json" // SiaDirMetadata is the name of the metadata file for the sia directory SiaDirMetadata = ".siadir" )
const ( // DefaultStreamCacheSize is the default cache size of the /renter/stream cache in // chunks, the user can set a custom cache size through the API DefaultStreamCacheSize = 2 )
Deprecated consts.
TODO: Tear out all related code and drop these consts.
const ( // PriceEstimationSafetyFactor is the factor of safety used in the price // estimation to account for any missed costs PriceEstimationSafetyFactor = 1.2 )
Constants which don't fit into another category very well.
Variables ¶
var ( //ErrBadFile is an error when a file does not qualify as .sia file ErrBadFile = errors.New("not a .sia file") // ErrIncompatible is an error when file is not compatible with current // version ErrIncompatible = errors.New("file is not compatible with current version") // ErrNoNicknames is an error when no nickname is given ErrNoNicknames = errors.New("at least one nickname must be supplied") // the defined share extension ErrNonShareSuffix = errors.New("suffix of file must be " + modules.SiaFileExtension) )
var ( // RepairThreshold defines the threshold at which the renter decides to // repair a file. The renter will start repairing the file when the health // is equal to or greater than this value. RepairThreshold = build.Select(build.Var{ Dev: 0.25, Standard: 0.25, Testing: 0.25, }).(float64) )
Default redundancy parameters.
Functions ¶
func NewDownloadDestinationBuffer ¶ added in v1.3.3
func NewDownloadDestinationBuffer() *downloadDestinationBuffer
NewDownloadDestinationBuffer allocates the necessary number of shards for the downloadDestinationBuffer and returns the new buffer.
Types ¶
type Renter ¶
type Renter struct {
// contains filtered or unexported fields
}
A Renter is responsible for tracking all of the files that a user has uploaded to Sia, as well as the locations and health of these files.
func New ¶
func New(g modules.Gateway, cs modules.ConsensusSet, wallet modules.Wallet, tpool modules.TransactionPool, persistDir string) (*Renter, error)
New returns an initialized renter.
func NewCustomRenter ¶ added in v1.3.3
func NewCustomRenter(g modules.Gateway, cs modules.ConsensusSet, tpool modules.TransactionPool, hdb hostDB, w modules.Wallet, hc hostContractor, persistDir string, deps modules.Dependencies) (*Renter, error)
NewCustomRenter initializes a renter and returns it.
func (*Renter) ActiveHosts ¶ added in v1.0.0
func (r *Renter) ActiveHosts() []modules.HostDBEntry
ActiveHosts returns an array of hostDB's active hosts
func (*Renter) AllHosts ¶ added in v1.0.0
func (r *Renter) AllHosts() []modules.HostDBEntry
AllHosts returns an array of all hosts
func (*Renter) BackupsOnHost ¶ added in v1.4.1
func (r *Renter) BackupsOnHost(hostKey types.SiaPublicKey) ([]modules.UploadedBackup, error)
BackupsOnHost returns the backups stored on a particular host. This operation can take multiple minutes if the renter is performing many other operations on this host, however this operation is given high priority over other types of operations.
func (*Renter) CancelContract ¶ added in v1.3.4
func (r *Renter) CancelContract(id types.FileContractID) error
CancelContract cancels a renter's contract by ID by setting goodForRenew and goodForUpload to false
func (*Renter) ClearDownloadHistory ¶ added in v1.3.4
ClearDownloadHistory clears the renter's download history inclusive of the provided before and after timestamps
TODO: This function can be improved by implementing a binary search, the trick will be making the binary search be just as readable while handling all the edge cases
func (*Renter) ContractUtility ¶ added in v1.3.2
func (r *Renter) ContractUtility(pk types.SiaPublicKey) (modules.ContractUtility, bool)
ContractUtility returns the utility field for a given contract, along with a bool indicating if it exists.
func (*Renter) Contracts ¶ added in v1.0.0
func (r *Renter) Contracts() []modules.RenterContract
Contracts returns an array of host contractor's staticContracts
func (*Renter) CreateBackup ¶ added in v1.4.0
CreateBackup creates a backup of the renter's siafiles. If a secret is not nil, the backup will be encrypted using the provided secret.
func (*Renter) CurrentPeriod ¶ added in v1.1.0
func (r *Renter) CurrentPeriod() types.BlockHeight
CurrentPeriod returns the host contractor's current period
func (*Renter) DeleteDir ¶ added in v1.4.0
DeleteDir removes a directory from the renter and deletes all its sub directories and files
func (*Renter) DeleteFile ¶ added in v0.3.1
DeleteFile removes a file entry from the renter and deletes its data from the hosts it is stored on.
func (*Renter) Download ¶
func (r *Renter) Download(p modules.RenterDownloadParameters) error
Download performs a file download using the passed parameters and blocks until the download is finished.
func (*Renter) DownloadAsync ¶ added in v1.3.3
func (r *Renter) DownloadAsync(p modules.RenterDownloadParameters, f func(error) error) (cancel func(), err error)
DownloadAsync performs a file download using the passed parameters without blocking until the download is finished.
func (*Renter) DownloadBackup ¶ added in v1.4.1
DownloadBackup downloads the specified backup.
func (*Renter) DownloadHistory ¶ added in v1.3.2
func (r *Renter) DownloadHistory() []modules.DownloadInfo
DownloadHistory returns the list of downloads that have been performed. Will include downloads that have not yet completed. Downloads will be roughly, but not precisely, sorted according to start time.
TODO: Currently the DownloadHistory only contains downloads from this session, does not contain downloads that were executed for the purposes of repairing, and has no way to clear the download history if it gets long or unwieldy. It's not entirely certain which of the missing features are actually desirable, please consult core team + app dev community before deciding what to implement.
func (*Renter) EstimateHostScore ¶ added in v1.3.0
func (r *Renter) EstimateHostScore(e modules.HostDBEntry, a modules.Allowance) (modules.HostScoreBreakdown, error)
EstimateHostScore returns the estimated host score
func (*Renter) File ¶ added in v1.3.3
File returns file from siaPath queried by user. Update based on FileList
func (*Renter) FileList ¶
func (r *Renter) FileList(siaPath modules.SiaPath, recursive, cached bool) ([]modules.FileInfo, error)
FileList returns all of the files that the renter has.
func (*Renter) Filter ¶ added in v1.4.1
func (r *Renter) Filter() (modules.FilterMode, map[string]types.SiaPublicKey, error)
Filter returns the renter's hostdb's filterMode and filteredHosts
func (*Renter) Host ¶ added in v1.1.1
func (r *Renter) Host(spk types.SiaPublicKey) (modules.HostDBEntry, bool)
Host returns the host associated with the given public key
func (*Renter) InitRecoveryScan ¶ added in v1.4.0
InitRecoveryScan starts scanning the whole blockchain for recoverable contracts within a separate thread.
func (*Renter) InitialScanComplete ¶ added in v1.3.3
InitialScanComplete returns a boolean indicating if the initial scan of the hostdb is completed.
func (*Renter) LoadBackup ¶ added in v1.4.0
LoadBackup loads the siafiles of a previously created backup into the renter. If the backup is encrypted, secret will be used to decrypt it. Otherwise the argument is ignored.
func (*Renter) OldContracts ¶ added in v1.3.4
func (r *Renter) OldContracts() []modules.RenterContract
OldContracts returns an array of host contractor's oldContracts
func (*Renter) PeriodSpending ¶ added in v1.3.1
func (r *Renter) PeriodSpending() modules.ContractorSpending
PeriodSpending returns the host contractor's period spending
func (*Renter) PriceEstimation ¶ added in v1.1.1
func (r *Renter) PriceEstimation(allowance modules.Allowance) (modules.RenterPriceEstimation, modules.Allowance, error)
PriceEstimation estimates the cost in siacoins of performing various storage and data operations. The estimation will be done using the provided allowance, if an empty allowance is provided then the renter's current allowance will be used if one is set. The final allowance used will be returned.
func (*Renter) ProcessConsensusChange ¶ added in v1.3.1
func (r *Renter) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange returns the process consensus change
func (*Renter) RecoverableContracts ¶ added in v1.4.0
func (r *Renter) RecoverableContracts() []modules.RecoverableContract
RecoverableContracts returns the host contractor's recoverable contracts.
func (*Renter) RecoveryScanStatus ¶ added in v1.4.0
func (r *Renter) RecoveryScanStatus() (bool, types.BlockHeight)
RecoveryScanStatus returns a bool indicating if a scan for recoverable contracts is in progress and if it is, the current progress of the scan.
func (*Renter) RefreshedContract ¶ added in v1.4.1
func (r *Renter) RefreshedContract(fcid types.FileContractID) bool
RefreshedContract returns a bool indicating if the contract was previously refreshed
func (*Renter) RenameDir ¶ added in v1.4.1
RenameDir takes an existing directory and changes the path. The original directory must exist, and there must not be any directory that already has the replacement path. All sia files within directory will also be renamed
func (*Renter) RenameFile ¶ added in v0.3.1
RenameFile takes an existing file and changes the nickname. The original file must exist, and there must not be any file that already has the replacement nickname.
func (*Renter) ScoreBreakdown ¶ added in v1.1.1
func (r *Renter) ScoreBreakdown(e modules.HostDBEntry) (modules.HostScoreBreakdown, error)
ScoreBreakdown returns the score breakdown
func (*Renter) SetFileStuck ¶ added in v1.4.1
SetFileStuck sets the Stuck field of the whole siafile to stuck.
func (*Renter) SetFileTrackingPath ¶ added in v1.3.5
SetFileTrackingPath sets the on-disk location of an uploaded file to a new value. Useful if files need to be moved on disk. SetFileTrackingPath will check that a file exists at the new location and it ensures that it has the right size, but it can't check that the content is the same. Therefore the caller is responsible for not accidentally corrupting the uploaded file by providing a different file with the same size.
func (*Renter) SetFilterMode ¶ added in v1.4.0
func (r *Renter) SetFilterMode(lm modules.FilterMode, hosts []types.SiaPublicKey) error
SetFilterMode sets the renter's hostdb filter mode
func (*Renter) SetIPViolationCheck ¶ added in v1.4.0
SetIPViolationCheck is a passthrough method to the hostdb's method of the same name.
func (*Renter) SetSettings ¶ added in v1.0.0
func (r *Renter) SetSettings(s modules.RenterSettings) error
SetSettings will update the settings for the renter.
NOTE: This function can't be atomic. Typically we try to have user requests be atomic, so that either everything changes or nothing changes, but since these changes happen progressively, it's possible for some of the settings (like the allowance) to succeed, but then if the bandwidth limits for example are bad, then the allowance will update but the bandwidth will not update.
func (*Renter) Settings ¶ added in v1.0.0
func (r *Renter) Settings() modules.RenterSettings
Settings returns the renter's allowance
func (*Renter) Streamer ¶ added in v1.3.3
Streamer creates a modules.Streamer that can be used to stream downloads from the sia network.
func (*Renter) Upload ¶
func (r *Renter) Upload(up modules.FileUploadParams) error
Upload instructs the renter to start tracking a file. The renter will automatically upload and repair tracked files using a background loop.
func (*Renter) UploadBackup ¶ added in v1.4.1
UploadBackup creates a backup of the renter which is uploaded to the sia network as a snapshot and can be retrieved using only the seed.
func (*Renter) UploadStreamFromReader ¶ added in v1.4.1
UploadStreamFromReader reads from the provided reader until io.EOF is reached and upload the data to the Sia network.
func (*Renter) UploadedBackups ¶ added in v1.4.1
func (r *Renter) UploadedBackups() ([]modules.UploadedBackup, []types.SiaPublicKey, error)
UploadedBackups returns the backups that the renter can download, along with a list of which contracts are storing all known backups.
type SectionWriter ¶ added in v1.4.1
type SectionWriter struct {
// contains filtered or unexported fields
}
SectionWriter implements Write on a section of an underlying WriterAt.
func NewSectionWriter ¶ added in v1.4.1
func NewSectionWriter(w io.WriterAt, off int64, n int64) *SectionWriter
NewSectionWriter returns a SectionWriter that writes to w starting at offset off and stops with EOF after n bytes.
type StreamShard ¶ added in v1.4.1
type StreamShard struct {
// contains filtered or unexported fields
}
StreamShard is a helper type that allows us to split an io.Reader up into multiple readers, wait for the shard to finish reading and then check the error for that Read.
func NewStreamShard ¶ added in v1.4.1
func NewStreamShard(r io.Reader) *StreamShard
NewStreamShard creates a new stream shard from a reader.
func (*StreamShard) Close ¶ added in v1.4.1
func (ss *StreamShard) Close() error
Close closes the underlying channel of the shard.
func (*StreamShard) Read ¶ added in v1.4.1
func (ss *StreamShard) Read(b []byte) (int, error)
Read implements the io.Reader interface. It closes signalChan after Read returns.
func (*StreamShard) Result ¶ added in v1.4.1
func (ss *StreamShard) Result() (int, error)
Result returns the returned values of calling Read on the shard.
Source Files
¶
- backup.go
- consts.go
- directoryheap.go
- dirs.go
- download.go
- downloadchunk.go
- downloaddestination.go
- downloadheap.go
- downloadstreamer.go
- files.go
- memory.go
- metadata.go
- persist.go
- persist_compat.go
- renter.go
- repair.go
- snapshot.go
- snapshotsession.go
- stuckstack.go
- upload.go
- uploadchunk.go
- uploadheap.go
- uploadstreamer.go
- worker.go
- workerdownload.go
- workerfetchbackups.go
- workerpool.go
- workerupload.go
Directories
¶
Path | Synopsis |
---|---|
Package contractor is responsible for forming and renewing file contracts with hosts.
|
Package contractor is responsible for forming and renewing file contracts with hosts. |
Package hostdb provides a HostDB object that implements the renter.hostDB interface.
|
Package hostdb provides a HostDB object that implements the renter.hostDB interface. |