code: func (c *connection) upload(msg func(pp.Message) bool) bool {
  	// Breaking or completing this loop means we don't want to upload to the
  	// peer anymore, and we choke them.
  another:
  	for c.uploadAllowed() {
  		// We want to upload to the peer.
  		if !c.Unchoke(msg) {
  			return false
  		}
  		for r := range c.PeerRequests {
  			res := c.t.cl.config.UploadRateLimiter.ReserveN(time.Now(), int(r.Length))
  			if !res.OK() {
  				panic(fmt.Sprintf("upload rate limiter burst size < %d", r.Length))
  			}
  			delay := res.Delay()
  			if delay > 0 {
  				res.Cancel()
  				c.setRetryUploadTimer(delay)
  				// Hard to say what to return here.
  				return true
  			}
  			more, err := c.sendChunk(r, msg)
  			if err != nil {
  				i := pieceIndex(r.Index)
  				if c.t.pieceComplete(i) {
  					c.t.updatePieceCompletion(i)
  					if !c.t.pieceComplete(i) {
  						// We had the piece, but not anymore.
  						break another
  					}
  				}
  				log.Str("error sending chunk to peer").AddValues(c, r, err).Log(c.t.logger)
  				// If we failed to send a chunk, choke the peer to ensure they
  				// flush all their requests. We've probably dropped a piece,
  				// but there's no way to communicate this to the peer. If they
  				// ask for it again, we'll kick them to allow us to send them
  				// an updated bitfield.
  				break another
  			}
  			delete(c.PeerRequests, r)
  			if !more {
  				return false
  			}
  			goto another
  		}
  		return true
  	}
  	return c.Choke(msg)
  }
docs: // Also handles choking and unchoking of the remote peer.