@Override
	public synchronized void handleBitfieldAvailability(SharingPeer peer,
			BitSet availablePieces) {
		// Determine if the peer is interesting for us or not, and notify it.
		BitSet interesting = (BitSet)availablePieces.clone();
		interesting.andNot(this.completedPieces);
		interesting.andNot(this.requestedPieces);

		if (interesting.cardinality() == 0) {
			peer.notInteresting();
		} else {
			peer.interesting();
		}

		// 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);
			this.rarest.remove(this.pieces[i]);
			this.rarest.add(this.pieces[i]);
		}

		logger.trace("Peer " + peer + " contributes " +
				availablePieces.cardinality() + " piece(s) [" +
				this.completedPieces.cardinality() + "/" +
				this.getAvailablePieces().cardinality() + "/" +
				this.pieces.length + "].");
	}