torrent: github.com/anacrolix/torrent/storage Index | Files

package storage

import "github.com/anacrolix/torrent/storage"

Package storage implements storage backends for package torrent.

Index

Package Files

boltPieceCompletion.go bolt_piece.go boltdb.go completion.go completion_piece_map.go doc.go file.go file_misc.go file_piece.go interface.go mmap.go piece_resource.go sqlitePieceCompletion.go wrappers.go

func CreateNativeZeroLengthFiles Uses

func CreateNativeZeroLengthFiles(info *metainfo.Info, dir string) (err error)

Creates natives files for any zero-length file entries in the info. This is a helper for file-based storages, which don't address or write to zero- length files because they have no corresponding pieces.

func NewSqlitePieceCompletion Uses

func NewSqlitePieceCompletion(dir string) (ret *sqlitePieceCompletion, err error)

type Client Uses

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

func NewClient Uses

func NewClient(cl ClientImpl) *Client

func (Client) OpenTorrent Uses

func (cl Client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (*Torrent, error)

type ClientImpl Uses

type ClientImpl interface {
    OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
    Close() error
}

Represents data storage for an unspecified torrent.

func NewBoltDB Uses

func NewBoltDB(filePath string) ClientImpl

func NewFile Uses

func NewFile(baseDir string) ClientImpl

All Torrent data stored in this baseDir

func NewFileByInfoHash Uses

func NewFileByInfoHash(baseDir string) ClientImpl

File storage with data partitioned by infohash.

func NewFileWithCompletion Uses

func NewFileWithCompletion(baseDir string, completion PieceCompletion) ClientImpl

func NewFileWithCustomPathMaker Uses

func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImpl

Allows passing a function to determine the path for storing torrent data

func NewMMap Uses

func NewMMap(baseDir string) ClientImpl

func NewMMapWithCompletion Uses

func NewMMapWithCompletion(baseDir string, completion PieceCompletion) ClientImpl

func NewResourcePieces Uses

func NewResourcePieces(p resource.Provider) ClientImpl

type Completion Uses

type Completion struct {
    Complete bool
    Ok       bool
}

type Piece Uses

type Piece struct {
    PieceImpl
    // contains filtered or unexported fields
}

func (Piece) ReadAt Uses

func (p Piece) ReadAt(b []byte, off int64) (n int, err error)

func (Piece) WriteAt Uses

func (p Piece) WriteAt(b []byte, off int64) (n int, err error)

type PieceCompletion Uses

type PieceCompletion interface {
    PieceCompletionGetSetter
    Close() error
}

Implementations track the completion of pieces. It must be concurrent-safe.

func NewBoltPieceCompletion Uses

func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error)

func NewMapPieceCompletion Uses

func NewMapPieceCompletion() PieceCompletion

type PieceCompletionGetSetter Uses

type PieceCompletionGetSetter interface {
    Get(metainfo.PieceKey) (Completion, error)
    Set(_ metainfo.PieceKey, complete bool) error
}

type PieceImpl Uses

type PieceImpl interface {
    // These interfaces are not as strict as normally required. They can
    // assume that the parameters are appropriate for the dimensions of the
    // piece.
    io.ReaderAt
    io.WriterAt
    // Called when the client believes the piece data will pass a hash check.
    // The storage can move or mark the piece data as read-only as it sees
    // fit.
    MarkComplete() error
    MarkNotComplete() error
    // Returns true if the piece is complete.
    Completion() Completion
}

Interacts with torrent piece data.

type Torrent Uses

type Torrent struct {
    TorrentImpl
}

func (Torrent) Piece Uses

func (t Torrent) Piece(p metainfo.Piece) Piece

type TorrentImpl Uses

type TorrentImpl interface {
    Piece(metainfo.Piece) PieceImpl
    Close() error
}

Data storage bound to a torrent.

Package storage imports 20 packages (graph) and is imported by 17 packages. Updated 2018-12-30. Refresh now. Tools for package owners.