Improve some doc comments
This commit is contained in:
parent
f408e19a7a
commit
8195e8df7b
|
@ -1053,7 +1053,8 @@ func (c *connection) receiveChunk(msg *pp.Message) {
|
||||||
// Need to record that it hasn't been written yet, before we attempt to do
|
// Need to record that it hasn't been written yet, before we attempt to do
|
||||||
// anything with it.
|
// anything with it.
|
||||||
piece.incrementPendingWrites()
|
piece.incrementPendingWrites()
|
||||||
// Record that we have the chunk.
|
// Record that we have the chunk, so we aren't trying to download it while
|
||||||
|
// waiting for it to be written to storage.
|
||||||
piece.unpendChunkIndex(chunkIndex(req.chunkSpec, t.chunkSize))
|
piece.unpendChunkIndex(chunkIndex(req.chunkSpec, t.chunkSize))
|
||||||
|
|
||||||
// Cancel pending requests for this chunk.
|
// Cancel pending requests for this chunk.
|
||||||
|
|
|
@ -66,6 +66,8 @@ func (info *Info) BuildFromFilePath(root string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Concatenates all the files in the torrent into w. open is a function that
|
||||||
|
// gets at the contents of the given file.
|
||||||
func (info *Info) writeFiles(w io.Writer, open func(fi FileInfo) (io.ReadCloser, error)) error {
|
func (info *Info) writeFiles(w io.Writer, open func(fi FileInfo) (io.ReadCloser, error)) error {
|
||||||
for _, fi := range info.UpvertedFiles() {
|
for _, fi := range info.UpvertedFiles() {
|
||||||
r, err := open(fi)
|
r, err := open(fi)
|
||||||
|
@ -81,7 +83,8 @@ func (info *Info) writeFiles(w io.Writer, open func(fi FileInfo) (io.ReadCloser,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set info.Pieces by hashing info.Files.
|
// Sets Pieces (the block of piece hashes in the Info) by using the passed
|
||||||
|
// function to get at the torrent data.
|
||||||
func (info *Info) GeneratePieces(open func(fi FileInfo) (io.ReadCloser, error)) error {
|
func (info *Info) GeneratePieces(open func(fi FileInfo) (io.ReadCloser, error)) error {
|
||||||
if info.PieceLength == 0 {
|
if info.PieceLength == 0 {
|
||||||
return errors.New("piece length must be non-zero")
|
return errors.New("piece length must be non-zero")
|
||||||
|
|
Loading…
Reference in New Issue