code: func (u *UploadHaves) Encode(w io.Writer, flush bool) error {
  	e := pktline.NewEncoder(w)
  
  	plumbing.HashesSort(u.Haves)
  
  	var last plumbing.Hash
  	for _, have := range u.Haves {
  		if bytes.Equal(last[:], have[:]) {
  			continue
  		}
  
  		if err := e.Encodef("have %s\n", have); err != nil {
  			return fmt.Errorf("sending haves for %q: %s", have, err)
  		}
  
  		last = have
  	}
  
  	if flush && len(u.Haves) != 0 {
  		if err := e.Flush(); err != nil {
  			return fmt.Errorf("sending flush-pkt after haves: %s", err)
  		}
  	}
  
  	return nil
  }
docs: // Encode encodes the UploadHaves into the Writer. If flush is true, a flush
  // command will be encoded at the end of the writer content.