}
}
+// Also handles choking and unchoking of the remote peer.
func (cl *Client) upload(t *Torrent, c *connection) {
if cl.config.NoUpload {
return
}
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)
}
func TestClientTransferVarious(t *testing.T) {
+ // Leecher storage
for _, ls := range []storageFactory{
NewFileCacheClientStorageFactory(FileCacheClientStorageFactoryParams{
Wrapper: fileCachePieceFileStorage,
}),
storage.NewBoltDB,
} {
+ // Seeder storage
for _, ss := range []func(string) storage.ClientImpl{
storage.NewFile,
storage.NewMMap,
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