예제 #1
0
파일: manager.py 프로젝트: kapetan/bitless
 def _send_have(self, index):
     with self._peers:
         for peer in self._peers:
             peer.have(index)
예제 #2
0
파일: manager.py 프로젝트: kapetan/bitless
 def _send_have(self, index):
     with self._peers:
         for peer in self._peers:
             peer.have(index)
예제 #3
0
파일: manager.py 프로젝트: kapetan/bitless
            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()
예제 #4
0
파일: manager.py 프로젝트: kapetan/bitless
            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()