public synchronized void piece(int index, int begin, byte[] block, Peer peer) {
        RequestExtended request = null;
        Set<RequestExtended> pendingRequests = null;
        
        pendingRequests = peerPendingRequests.get(peer);
        if (pendingRequests != null){
            for (RequestExtended re : pendingRequests){
                if (re.getIndex() == index && re.getBegin() == begin && re.getLength() == block.length){
                    request = re;
                    break;
                }
            }
            if (request != null){
                pendingRequests.remove(request);
                if (pendingRequests.size() == 0)
                    peerPendingRequests.remove(peer);
                request.getPeers().remove(peer);
                
                /*
                 * Cancel the same request to all the other peers
                 */
                for (Peer p : request.getPeers()) {
                    p.sendMessage(new Cancel(index,begin,block.length));
                    pendingRequests = peerPendingRequests.get(p);
                    pendingRequests.remove(request);
                    if (pendingRequests.size() == 0)
                        peerPendingRequests.remove(p);
                }
                
                piecePendingRequests.get(index).remove(request);
                allPendingRequests.remove(request);
            }
        } 
        /*
         * else, the peer is sending us a block we didn't request
         * or a block we already canceled
         */
        
    }