Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function comments based on best practices from Effective Go #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torrent/bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewBitset(n int) *Bitset {
return &Bitset{make([]byte, (n+7)>>3), n, endIndex, endMask}
}

// Creates a new bitset from a given byte stream. Returns nil if the
// NewBitsetFromBytes: Creates a new bitset from a given byte stream. Returns nil if the
// data is invalid in some way.
func NewBitsetFromBytes(n int, data []byte) *Bitset {
bitset := NewBitset(n)
Expand Down
2 changes: 1 addition & 1 deletion torrent/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (r *RamCache) trim() {
}
}

//Simple utility for dumping a []byte to log.
// Dump: Simple utility for dumping a []byte to log.
//It skips over sections of '0', unlike encoding/hex.Dump()
func Dump(buff []byte) {
log.Println("Dumping []byte len=", len(buff))
Expand Down
6 changes: 3 additions & 3 deletions torrent/metainfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (f *FileStoreFileAdapter) Close() (err error) {
return f.f.Close()
}

// Create a MetaInfo for a given file and file system.
// CreateMetaInfoFromFileSystem: Create a MetaInfo for a given file and file system.
// If fs is nil then the OSMetaInfoFileSystem will be used.
// If pieceLength is 0 then an optimal piece length will be chosen.
func CreateMetaInfoFromFileSystem(fs MetaInfoFileSystem, root, tracker string, pieceLength int64, wantMD5Sum bool) (metaInfo *MetaInfo, err error) {
Expand Down Expand Up @@ -408,7 +408,7 @@ func (m *MetaInfo) addFiles(fs MetaInfoFileSystem, file string) (err error) {
return
}

// Updates the InfoHash field. Call this after manually changing the Info data.
// UpdateInfoHash: Updates the InfoHash field. Call this after manually changing the Info data.
func (m *MetaInfo) UpdateInfoHash(metaInfo *MetaInfo) (err error) {
var b bytes.Buffer
infoMap := m.Info.toMap()
Expand Down Expand Up @@ -475,7 +475,7 @@ func (i *InfoDict) toMap() (m map[string]interface{}) {
return
}

// Encode to Bencode, but only encode non-default values.
// Bencode: Encode to Bencode, but only encode non-default values.
func (m *MetaInfo) Bencode(w io.Writer) (err error) {
var mi map[string]interface{} = map[string]interface{}{}
id := m.Info.toMap()
Expand Down
2 changes: 1 addition & 1 deletion torrent/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SftpFsProvider struct {
ServerPath string
}

//Connection string: username:[email protected]:8042/over/there/
// NewSftpFsProvider: Connection string: username:[email protected]:8042/over/there/
func NewSftpFsProvider(connection string) SftpFsProvider {
connSA := strings.Split(connection, "@")
authSA := strings.Split(connSA[0], ":")
Expand Down
4 changes: 2 additions & 2 deletions torrent/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (ts *TorrentSession) Header() (header []byte) {
return ts.torrentHeader
}

// Try to connect if the peer is not already in our peers.
// HintNewPeer: Try to connect if the peer is not already in our peers.
// Can be called from any goroutine.
func (ts *TorrentSession) HintNewPeer(peer string) {
if len(ts.hintNewPeerChan) < cap(ts.hintNewPeerChan) { //We don't want to block the main loop because a single torrent is having problems
Expand Down Expand Up @@ -427,7 +427,7 @@ func (ts *TorrentSession) AcceptNewPeer(btconn *BtConn) {
ts.AddPeer(btconn)
}

// Can be called from any goroutine
// AddPeer: Can be called from any goroutine
func (ts *TorrentSession) AddPeer(btconn *BtConn) {
if len(ts.addPeerChan) < cap(ts.addPeerChan) { //We don't want to block the main loop because a single torrent is having problems
select {
Expand Down
2 changes: 1 addition & 1 deletion tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func newTrackerPeerListenAddress(requestRemoteAddr string, params *announceParam
return net.ResolveTCPAddr("tcp", net.JoinHostPort(host, strconv.Itoa(params.port)))
}

// Start a tracker and run it until interrupted.
// StartTracker starts a tracker and run it until interrupted.
func StartTracker(addr string, torrentFiles []string) (err error) {
t := NewTracker()
// TODO(jackpal) Allow caller to choose port number
Expand Down