Beispiel #1
0
 def _send_have(self, index):
     with self._peers:
         for peer in self._peers:
             peer.have(index)
Beispiel #2
0
 def _send_have(self, index):
     with self._peers:
         for peer in self._peers:
             peer.have(index)
Beispiel #3
0
            self._torrent = t

        def has(self, piece):
            return False

        def completed(self):
            return False

        def piece(self, index):
            return storage.Piece.create_empty_piece(\
                index, 256000, self._torrent.piece_hash(index))

        def write_piece(self, piece):
            print("Writting piece ", piece)

    manager = PeerManager(peer_id, t, None, None, StorageMock(t))
    peer = peer.handshake(sock, addr, peer_id, t, manager)

    field = bitfield.Bitfield(t.number_of_pieces)
    #for i in range(len(field)):
    #    if random.random() < 0.5:
    #        field.set(i)
    field.set(8)

    peer.bitfield(field)
    peer.choke(True)
    peer.choke(False)
    peer.have(9)
    time.sleep(5)
    peer.close()
Beispiel #4
0
            self._torrent = t

        def has(self, piece):
            return False

        def completed(self):
            return False

        def piece(self, index):
            return storage.Piece.create_empty_piece(\
                index, 256000, self._torrent.piece_hash(index))

        def write_piece(self, piece):
            print("Writting piece ", piece)

    manager = PeerManager(peer_id, t, None, None, StorageMock(t))
    peer = peer.handshake(sock, addr, peer_id, t, manager)

    field = bitfield.Bitfield(t.number_of_pieces)
    #for i in range(len(field)):
    #    if random.random() < 0.5:
    #        field.set(i)
    field.set(8)

    peer.bitfield(field)
    peer.choke(True)
    peer.choke(False)
    peer.have(9)
    time.sleep(5)
    peer.close()