]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Improve code comments
authorMatt Joiner <anacrolix@gmail.com>
Mon, 10 Oct 2016 03:57:34 +0000 (14:57 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 10 Oct 2016 03:57:34 +0000 (14:57 +1100)
client.go
client_test.go
config.go

index 238190967d75b6ced78b8ebf5a2059d70fe37e61..e0aa472ae1bcebbe7c2be2dd3bef165e490a8471 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1066,6 +1066,7 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *connect
        }
 }
 
+// Also handles choking and unchoking of the remote peer.
 func (cl *Client) upload(t *Torrent, c *connection) {
        if cl.config.NoUpload {
                return
@@ -1075,10 +1076,14 @@ func (cl *Client) upload(t *Torrent, c *connection) {
        }
        seeding := t.seeding()
        if !seeding && !t.connHasWantedPieces(c) {
+               // There's no reason to upload to this peer.
                return
        }
+       // Breaking or completing this loop means we don't want to upload to the
+       // peer anymore, and we choke them.
 another:
        for seeding || c.chunksSent < c.UsefulChunksReceived+6 {
+               // We want to upload to the peer.
                c.Unchoke()
                for r := range c.PeerRequests {
                        err := cl.sendChunk(t, c, r)
index 835ca1b89f37b508786344a2654ab800c9e45333..cc1ab59436ee22b2de98ae4db44e74684c66f4a4 100644 (file)
@@ -296,6 +296,7 @@ func TestClientTransferSmallCache(t *testing.T) {
 }
 
 func TestClientTransferVarious(t *testing.T) {
+       // Leecher storage
        for _, ls := range []storageFactory{
                NewFileCacheClientStorageFactory(FileCacheClientStorageFactoryParams{
                        Wrapper: fileCachePieceFileStorage,
@@ -305,6 +306,7 @@ func TestClientTransferVarious(t *testing.T) {
                }),
                storage.NewBoltDB,
        } {
+               // Seeder storage
                for _, ss := range []func(string) storage.ClientImpl{
                        storage.NewFile,
                        storage.NewMMap,
index dbcdbd137feb430785f6b5b5c44f6ea542a4cbdc..cb52d3cdc05f3d9c3946d2185c7912b0914cf0b1 100644 (file)
--- a/config.go
+++ b/config.go
@@ -22,10 +22,12 @@ type Config struct {
        NoDHT bool `long:"disable-dht"`
        // Overrides the default DHT configuration.
        DHTConfig dht.ServerConfig
-       // Don't ever send chunks to peers.
+
+       // Never send chunks to peers.
        NoUpload bool `long:"no-upload"`
        // Upload even after there's nothing in it for us. By default uploading is
-       // not altruistic.
+       // not altruistic, we'll upload slightly more than we download from each
+       // peer.
        Seed bool `long:"seed"`
        // User-provided Client peer ID. If not present, one is generated automatically.
        PeerID string