Improve code comments
This commit is contained in:
parent
510c03770b
commit
76c24e70b5
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue