2
0
mirror of synced 2025-02-24 14:48:27 +00:00
torrent/storage/interface.go
Matt Joiner 5e83287890 storage: ClientImpl interface now includes Close
This is now necessary because bolt doesn't allow multiple DB handles, so the bolt piece completion DB instance must be at the client level. The new method is not currently used from the Client however, this maybe necessary to avoid leaks.
2016-10-25 20:00:09 +11:00

36 lines
888 B
Go

package storage
import (
"io"
"github.com/anacrolix/torrent/metainfo"
)
// Represents data storage for an unspecified torrent.
type ClientImpl interface {
OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
Close() error
}
// Data storage bound to a torrent.
type TorrentImpl interface {
Piece(metainfo.Piece) PieceImpl
Close() error
}
// Interacts with torrent piece data.
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.
GetIsComplete() bool
}