renter

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PersistFilename = "renter.dat"
	PersistHeader   = "Renter Persistence"
	PersistVersion  = "0.2"

	ShareExtension = ".sia"
	ShareHeader    = "Sia Shared File"
	ShareVersion   = "0.1"
)

Variables

View Source
var (
	ErrUnknownNickname  = errors.New("no file known by that nickname")
	ErrNicknameOverload = errors.New("a file with the proposed nickname already exists")
)
View Source
var (
	ErrUnrecognizedHeader  = errors.New("renter persistence file has unrecognized header")
	ErrUnrecognizedVersion = errors.New("renter persistence file has unrecognized version")

	ErrNoNicknames    = errors.New("at least one nickname must be supplied")
	ErrNonShareSuffix = errors.New("suffix of file must be " + ShareExtension)
)
View Source
var (
	ErrNilCS     = errors.New("cannot create renter with nil consensus set")
	ErrNilHostDB = errors.New("cannot create renter with nil hostdb")
	ErrNilWallet = errors.New("cannot create renter wil nil wlalet")
)

Functions

This section is empty.

Types

type Download

type Download struct {
	// contains filtered or unexported fields
}

A Download is a file download that has been queued by the renter.

func (*Download) Complete

func (d *Download) Complete() bool

Complete returns whether the file is ready to be used.

func (*Download) Destination

func (d *Download) Destination() string

Destination returns the file's location on disk.

func (*Download) Filesize

func (d *Download) Filesize() uint64

Filesize returns the size of the file.

func (*Download) Nickname

func (d *Download) Nickname() string

Nickname returns the identifier assigned to the file when it was uploaded.

func (*Download) Received

func (d *Download) Received() uint64

Received returns the number of bytes downloaded so far.

func (*Download) Write

func (d *Download) Write(b []byte) (int, error)

Write implements the io.Writer interface. Each write updates the Download's received field. This allows download progress to be monitored in real-time.

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(cs *consensus.State, hdb modules.HostDB, wallet modules.Wallet, saveDir string) (*Renter, error)

New returns an empty renter.

func (*Renter) DeleteFile added in v0.3.1

func (r *Renter) DeleteFile(nickname string) error

DeleteFile removes a file entry from the renter.

func (*Renter) Download

func (r *Renter) Download(nickname, destination string) error

Download downloads a file, identified by its nickname, to the destination specified.

func (*Renter) DownloadQueue

func (r *Renter) DownloadQueue() []modules.DownloadInfo

DownloadQueue returns the list of downloads in the queue.

func (*Renter) FileList

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

FileList returns all of the files that the renter has.

func (*Renter) Info

func (r *Renter) Info() (ri modules.RentInfo)

Info returns generic information about the renter and the files that are being rented.

func (*Renter) LoadSharedFile added in v0.3.1

func (r *Renter) LoadSharedFile(filename string) ([]string, error)

LoadSharedFile loads a shared file into the renter.

func (*Renter) LoadSharedFilesAscii added in v0.3.1

func (r *Renter) LoadSharedFilesAscii(asciiSia string) ([]string, error)

loadSharedFile takes an encoded set of files and adds them to the renter, taking them form an ascii string.

func (*Renter) ReceiveConsensusSetUpdate added in v0.3.1

func (r *Renter) ReceiveConsensusSetUpdate(revertedBlocks []types.Block, appliedBlocks []types.Block)

ReceiveConsensusSetUpdate will be called by the consensus set every time there is a change in the blockchain. Updates will always be called in order.

func (*Renter) RenameFile added in v0.3.1

func (r *Renter) RenameFile(currentName, newName string) 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) RenterNotify added in v0.3.1

func (r *Renter) RenterNotify() <-chan struct{}

RenterNotify returns a channel that will be sent a struct{} every time there is an update received from another module.

func (*Renter) ShareFiles added in v0.3.1

func (r *Renter) ShareFiles(nicknames []string, sharedest string) error

ShareFiles saves a '.sia' file that can be shared with others, enabling them to download the file you are sharing. It creates a Sia equivalent of a '.torrent'.

func (*Renter) ShareFilesAscii added in v0.3.1

func (r *Renter) ShareFilesAscii(nicknames []string) (string, error)

ShareFilesAscii returns an ascii string that can be shared with other daemons, granting them access to the files.

func (*Renter) Upload

func (r *Renter) Upload(up modules.FileUploadParams) error

Upload takes an upload parameters, which contain a file to upload, and then creates a redundant copy of the file on the Sia network.

type RenterPersistence added in v0.3.1

type RenterPersistence struct {
	Header  string
	Version string
	Files   []file
}

RenterPersistence is the struct that gets written to and read from disk as the renter is saved and loaded.

type RenterSharedFile added in v0.3.1

type RenterSharedFile struct {
	Header  string
	Version string
	Files   []file
}

RenterSharedFile is the struct that gets written to and read from disk when sharing files.

Jump to

Keyboard shortcuts

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