renter

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package renter is responsible for uploading and downloading files on the sia network.

Index

Constants

View Source
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.

View Source
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"
)
View Source
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.

View Source
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

View Source
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")
	// ErrNonShareSuffix is an error when the suffix of a file does not match
	// the defined share extension
	ErrNonShareSuffix = errors.New("suffix of file must be " + modules.SiaFileExtension)
)

Functions

func NewDownloadDestinationBuffer added in v1.3.3

func NewDownloadDestinationBuffer(length, pieceSize uint64) 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.

TODO: Separate the workerPool to have its own mutex. The workerPool doesn't interfere with any of the other fields in the renter, should be fine for it to have a separate mutex, that way operations on the worker pool don't block operations on other parts of the struct. If we're going to do it that way, might make sense to split the worker pool off into it's own struct entirely the same way that we split of the memoryManager entirely.

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, 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) 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

func (r *Renter) ClearDownloadHistory(after, before time.Time) error

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) Close added in v1.0.0

func (r *Renter) Close() error

Close closes the Renter and its dependencies

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

func (r *Renter) CreateBackup(dst string, secret []byte) error

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) CreateDir added in v1.4.0

func (r *Renter) CreateDir(siaPath modules.SiaPath) error

CreateDir creates a directory for the renter

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

func (r *Renter) DeleteDir(siaPath modules.SiaPath) error

DeleteDir removes a directory from the renter and deletes all its sub directories and files

func (*Renter) DeleteFile added in v0.3.1

func (r *Renter) DeleteFile(siaPath modules.SiaPath) error

DeleteFile removes a file entry from the renter and deletes its data from the hosts it is stored on.

func (*Renter) DirInfo added in v1.4.0

func (r *Renter) DirInfo(siaPath modules.SiaPath) (modules.DirectoryInfo, error)

DirInfo returns the Directory Information of the siadir

func (*Renter) DirList added in v1.4.0

func (r *Renter) DirList(siaPath modules.SiaPath) ([]modules.DirectoryInfo, []modules.FileInfo, error)

DirList returns directories and files stored in the siadir as well as the DirectoryInfo of the siadir

func (*Renter) Download

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) error

DownloadAsync performs a file download using the passed parameters without blocking until the download is finished.

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

EstimateHostScore returns the estimated host score

func (*Renter) File added in v1.3.3

func (r *Renter) File(siaPath modules.SiaPath) (modules.FileInfo, error)

File returns file from siaPath queried by user. Update based on FileList

func (*Renter) FileList

func (r *Renter) FileList() ([]modules.FileInfo, error)

FileList returns all of the files that the renter has.

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

func (r *Renter) InitRecoveryScan() error

InitRecoveryScan starts scanning the whole blockchain for recoverable contracts within a separate thread.

func (*Renter) InitialScanComplete added in v1.3.3

func (r *Renter) InitialScanComplete() (bool, error)

InitialScanComplete returns a boolean indicating if the initial scan of the hostdb is completed.

func (*Renter) LoadBackup added in v1.4.0

func (r *Renter) LoadBackup(src string, secret []byte) error

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) RenameFile added in v0.3.1

func (r *Renter) RenameFile(currentName, newName modules.SiaPath) error

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) SetFileTrackingPath added in v1.3.5

func (r *Renter) SetFileTrackingPath(siaPath modules.SiaPath, newPath string) error

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

func (r *Renter) SetIPViolationCheck(enabled bool)

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

func (r *Renter) Streamer(siaPath modules.SiaPath) (string, modules.Streamer, error)

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL