Documentation ¶
Overview ¶
bittorrent data storage backend
Index ¶
- Variables
- type FsStorage
- func (st *FsStorage) Close() (err error)
- func (st *FsStorage) CreateNewBitfield(ih common.Infohash, bits uint32)
- func (st *FsStorage) EmptyTorrent(ih common.Infohash) (t Torrent)
- func (st *FsStorage) FindBitfield(ih common.Infohash) (bf *bittorrent.Bitfield)
- func (st *FsStorage) HasBitfield(ih common.Infohash) bool
- func (st *FsStorage) Init() (err error)
- func (st *FsStorage) OpenAllTorrents() (torrents []Torrent, err error)
- func (st *FsStorage) OpenTorrent(info *metainfo.TorrentFile) (t Torrent, err error)
- func (st *FsStorage) PollNewTorrents() (torrents []Torrent)
- func (st *FsStorage) Run()
- type IOP
- type Storage
- type Torrent
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMetaInfoMissmatch = errors.New("torrent infohash does not match")
View Source
var ErrNoMetaInfo = errors.New("no torrent file")
Functions ¶
This section is empty.
Types ¶
type FsStorage ¶
type FsStorage struct { // directory for seeding data SeedingDir string // directory for downloaded data DataDir string // directory for torrent seed data MetaDir string // filesystem driver FS fs.Driver // number of io worker threads Workers int // IOP channel buffer size IOPBufferSize int // contains filtered or unexported fields }
filesystem based torrent storage
func (*FsStorage) CreateNewBitfield ¶
func (*FsStorage) FindBitfield ¶
func (st *FsStorage) FindBitfield(ih common.Infohash) (bf *bittorrent.Bitfield)
func (*FsStorage) OpenAllTorrents ¶
func (*FsStorage) OpenTorrent ¶
func (st *FsStorage) OpenTorrent(info *metainfo.TorrentFile) (t Torrent, err error)
func (*FsStorage) PollNewTorrents ¶
type Storage ¶
type Storage interface { // Close and flush storage backend Close() error // create a torrent with no meta info EmptyTorrent(ih common.Infohash) Torrent // open a storage session for a torrent // does not verify any piece data OpenTorrent(info *metainfo.TorrentFile) (Torrent, error) // open all torrents tracked by this storage // does not verify any piece data OpenAllTorrents() ([]Torrent, error) // intialize backend Init() error // returns nil if we have no new torrents added from backend // returns next new torrents added to storage PollNewTorrents() []Torrent // run mainloop Run() }
torrent storage driver
type Torrent ¶
type Torrent interface { // allocate all files for download Allocate() error // verify all piece data VerifyAll() error // return true if we are currently doing a deep check Checking() bool // put a chunk of data PutChunk(pc *common.PieceData) error // visit a piece from storage GetPiece(r common.PieceRequest, pc *common.PieceData) error // verify a piece by index VerifyPiece(idx uint32) error // get metainfo MetaInfo() *metainfo.TorrentFile // get infohash Infohash() common.Infohash // get bitfield, if cached return cache otherwise compute and cache Bitfield() *bittorrent.Bitfield // get number of bytes we already downloaded DownloadedSize() uint64 // get number of bytes remaining we need to download DownloadRemaining() uint64 // flush bitfield to disk Flush() error // get name of this torrent Name() string // delete all files and metadata for this torrent Delete() error // save torrent stats SaveStats(s *stats.Tracker) error // get a list of files for this torrent // returns absolute path of all downloaded files FileList() []string // move data files to other directory, blocks for a LONG time MoveTo(other string) error // verify data and move to seeding directory Seed() (bool, error) // set metainfo for empty torrent PutInfoBytes(info []byte) error // get directory for data files DownloadDir() string }
storage session for 1 torrent
Click to show internal directories.
Click to hide internal directories.