Documentation ¶
Index ¶
- Variables
- type FileStorage
- func (s *FileStorage) HashPiece(pieceIndex, len int) (correct bool)
- func (s *FileStorage) ReadAt(b []byte, off int64) (n int, err error)
- func (s *FileStorage) ReadBlock(b []byte, off int64) (n int, err error)
- func (s *FileStorage) WriteAt(p []byte, off int64) (n int, err error)
- func (s *FileStorage) WriteBlock(p []byte, off int64) (n int, err error)
- type Open
- type Storage
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyWritten = errors.New("storage: trying to write at already written block")
View Source
var ErrNotReadyForVerification = errors.New("storage: not all piece's blocks are written")
View Source
var ErrReadNonVerified = errors.New("storage: trying to read non verified piece")
Functions ¶
This section is empty.
Types ¶
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage is a file-based storage for torrent data
func (*FileStorage) HashPiece ¶
func (s *FileStorage) HashPiece(pieceIndex, len int) (correct bool)
HashPiece hashes `pieceIndex` whose length is `len` and returns if the hash was the expected.
func (*FileStorage) ReadAt ¶
func (s *FileStorage) ReadAt(b []byte, off int64) (n int, err error)
Only returns EOF at the end of the torrent. Premature EOF is ErrUnexpectedEOF.
func (*FileStorage) ReadBlock ¶
func (s *FileStorage) ReadBlock(b []byte, off int64) (n int, err error)
ReadBlock is like ReadAt but fails if the piece to be read is not verified
func (*FileStorage) WriteBlock ¶
func (s *FileStorage) WriteBlock(p []byte, off int64) (n int, err error)
WriteBlock behaves like WriteAt but it fails if another write has occured at the same offset
type Open ¶
type Open func(mi *metainfo.MetaInfo, baseDir string, blocks []int, logger *log.Logger) (s Storage, seed bool)
Open returns a Storage object
Click to show internal directories.
Click to hide internal directories.