Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Nov 11, 2021
1 parent 57c5445 commit cb57787
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/piecepicker/webseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
// WebseedDownloadSpec contains information for downloading torrent data from webseed sources.
type WebseedDownloadSpec struct {
Source *webseedsource.WebseedSource
Begin uint32
End uint32
Begin uint32 // piece index
End uint32 // piece index
}

// PickWebseed returns the next spec for downloading files from webseed sources.
func (p *PiecePicker) PickWebseed(src *webseedsource.WebseedSource) *WebseedDownloadSpec {
begin, end := p.findRangeForWebseed()
begin, end := p.findPieceRangeForWebseed()
if begin == end {
return nil
}
Expand All @@ -43,7 +43,7 @@ func (p *PiecePicker) downloadingWebseed() bool {
return false
}

func (p *PiecePicker) findRangeForWebseed() (begin, end uint32) {
func (p *PiecePicker) findPieceRangeForWebseed() (begin, end uint32) {
gaps := p.findGaps()
if len(gaps) == 0 {
gap := p.webseedStealsFromAnotherWebseed()
Expand Down Expand Up @@ -157,7 +157,7 @@ func (p *PiecePicker) pickLastPieceOfSmallestGap(pe *peer.Peer) *myPiece {
return nil
}

// Range is a piece range.
// Range is a piece index range.
// Begin is inclusive, End is exclusive.
type Range struct {
Begin, End uint32
Expand Down
2 changes: 1 addition & 1 deletion internal/urldownloader/urldownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type PieceResult struct {
Buffer bufferpool.Buffer
Index uint32
Error error
Done bool
Done bool // URL downloader finished downloading all requested pieces
}

// New returns a new URLDownloader for the given source and piece range.
Expand Down

0 comments on commit cb57787

Please sign in to comment.