diff --git a/torrent/bitset.go b/torrent/bitset.go index 4cb46fe..b9baf2e 100644 --- a/torrent/bitset.go +++ b/torrent/bitset.go @@ -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) diff --git a/torrent/cache.go b/torrent/cache.go index c561f62..2187ab6 100644 --- a/torrent/cache.go +++ b/torrent/cache.go @@ -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)) diff --git a/torrent/metainfo.go b/torrent/metainfo.go index 8eec0c9..44bc10d 100644 --- a/torrent/metainfo.go +++ b/torrent/metainfo.go @@ -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) { @@ -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() @@ -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() diff --git a/torrent/sftp.go b/torrent/sftp.go index a6a89dc..c1126ed 100644 --- a/torrent/sftp.go +++ b/torrent/sftp.go @@ -20,7 +20,7 @@ type SftpFsProvider struct { ServerPath string } -//Connection string: username:password@example.com:8042/over/there/ +// NewSftpFsProvider: Connection string: username:password@example.com:8042/over/there/ func NewSftpFsProvider(connection string) SftpFsProvider { connSA := strings.Split(connection, "@") authSA := strings.Split(connSA[0], ":") diff --git a/torrent/torrent.go b/torrent/torrent.go index 1b760f8..a3b1014 100644 --- a/torrent/torrent.go +++ b/torrent/torrent.go @@ -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 @@ -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 { diff --git a/tracker/tracker.go b/tracker/tracker.go index c8d1940..07d16de 100644 --- a/tracker/tracker.go +++ b/tracker/tracker.go @@ -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