Exemple #1
0
  void haveMessage(int piece) {
    if (_log.shouldLog(Log.DEBUG)) _log.debug(peer + " rcv have(" + piece + ")");
    // FIXME we will lose these until we get the metainfo
    if (metainfo == null) return;
    // Sanity check
    if (piece < 0 || piece >= metainfo.getPieces()) {
      // XXX disconnect?
      if (_log.shouldLog(Log.WARN))
        _log.warn("Got strange 'have: " + piece + "' message from " + peer);
      return;
    }

    synchronized (this) {
      // Can happen if the other side never send a bitfield message.
      if (bitfield == null) bitfield = new BitField(metainfo.getPieces());

      bitfield.set(piece);
    }

    if (listener.gotHave(peer, piece)) setInteresting(true);
  }
Exemple #2
0
 public void testSetBoolean() {
   assertEquals(bf_multi.set(0), bf_multi.setBoolean(0, true));
   assertEquals(bf_single.set(0), bf_single.setBoolean(0, true));
   assertEquals(bf_multi.clear(-1), bf_multi.setBoolean(-1, false));
   assertEquals(bf_single.clear(-1), bf_single.setBoolean(-1, false));
 }
Exemple #3
0
 public void testSet() {
   assertEquals(bf_multi.set(0), 0x3F80);
   assertEquals(bf_single.set(0), 0x4000);
 }