code: @Override
    public void handleBitfieldAvailability(SharingPeer peer,
                                           BitSet availablePieces) {
      // Determine if the peer is interesting for us or not, and notify it.
      BitSet interesting = (BitSet) availablePieces.clone();
      synchronized (this) {
        interesting.andNot(this.completedPieces);
        interesting.andNot(this.requestedPieces);
      }
      // Record the peer has all the pieces it told us it had.
      for (int i = availablePieces.nextSetBit(0); i >= 0;
           i = availablePieces.nextSetBit(i + 1)) {
        this.pieces[i].seenAt(peer);
      }
  
      if (interesting.cardinality() == 0) {
        peer.notInteresting();
      } else {
        peer.interesting();
      }
  
      logger.debug("Peer {} contributes {} piece(s), total pieces count: {}.",
              new Object[]{
                      peer,
                      availablePieces.cardinality(),
                      myTorrentMetadata.getPiecesCount()
              });
    }
docs: Bit field availability handler.
  <p/>
  <p>
  Handle updates in piece availability from a peer's BITFIELD message.
  When this happens, we need to mark in all the pieces the peer has that
  they can be reached through this peer, thus augmenting the global
  availability of pieces.
  </p>
  
  @param peer            The peer we got the update from.
  @param availablePieces The pieces availability bit field of the peer.