def __init__(self, torrent_hash, num_pieces, coordinator_permid, coordinator = None):
        self.overlay_bridge = OverlayThreadingBridge.getInstance()
        self.torrent_hash = torrent_hash
        if coordinator_permid is not None and coordinator_permid == '':
            self.coordinator_permid = None
        else:
            self.coordinator_permid = coordinator_permid
        self.coordinator_ip = None  # see is_coordinator()
        self.coordinator_port = -1

        if self.coordinator_permid is not None:
            peerdb = PeerDBHandler.getInstance()
            peer = peerdb.getPeer(coordinator_permid)
            if peer is not None:
                self.coordinator_ip = peer['ip']
                self.coordinator_port = peer['port']

        self.reserved_pieces = [False] * num_pieces
        self.ignored_pieces = [False] * num_pieces
        self.coordinator = coordinator
        self.counter = 0
        self.completed = False
        self.distr_reserved_pieces = [False] * num_pieces
        self.marker = [True] * num_pieces
        self.round = 0
        self.encoder = None
        self.continuations = []
        self.outstanding = None
        self.last_req_time = 0
Example #2
0
    def __init__(self,
                 torrent_hash,
                 num_pieces,
                 coordinator_permid,
                 coordinator=None):
        self.overlay_bridge = OverlayThreadingBridge.getInstance()
        self.torrent_hash = torrent_hash
        if coordinator_permid is not None and coordinator_permid == '':
            self.coordinator_permid = None
        else:
            self.coordinator_permid = coordinator_permid
        self.coordinator_ip = None  # see is_coordinator()
        self.coordinator_port = -1

        if self.coordinator_permid is not None:
            peerdb = PeerDBHandler.getInstance()
            peer = peerdb.getPeer(coordinator_permid)
            if peer is not None:
                self.coordinator_ip = peer['ip']
                self.coordinator_port = peer['port']

        self.reserved_pieces = [False] * num_pieces
        self.ignored_pieces = [False] * num_pieces
        self.coordinator = coordinator
        self.counter = 0
        self.completed = False
        self.distr_reserved_pieces = [False] * num_pieces
        self.marker = [True] * num_pieces
        self.round = 0
        self.encoder = None
        self.continuations = []
        self.outstanding = None
        self.last_req_time = 0
    def test_loadSuperPeer(self):
        """ The SuperPeerDBHandler constructor writes the superpeers to the PeerDB """

        self.splist.loadSuperPeers(self.config, True)
        assert self.splist.size() == 3, self.splist.size()

        self.peer_db = PeerDBHandler.getInstance()
        # Arno: must be 3, as there is a duplicate PermID in the lines list
        assert self.peer_db.size() == 3, self.peer_db.size()
 def test_loadSuperPeer(self):
     """ The SuperPeerDBHandler constructor writes the superpeers to the PeerDB """
     
     self.splist.loadSuperPeers(self.config, True)
     assert self.splist.size() == 3, self.splist.size()
     
     self.peer_db = PeerDBHandler.getInstance()
     # Arno: must be 3, as there is a duplicate PermID in the lines list
     assert self.peer_db.size() == 3, self.peer_db.size()
 def __init__(self):
     if FriendshipMsgHandler.__singleton:
         raise RuntimeError, "FriendshipMsgHandler is singleton"
     self.overlay_bridge = None
     self.currmsgs = {}
     self.online_fsext_peers = Set() # online peers that speak FRIENDSHIP ext
     self.peerdb = PeerDBHandler.getInstance()
     self.frienddb = FriendDBHandler.getInstance()
     self.friendshipStatistics_db = FriendshipStatisticsDBHandler.getInstance()
     self.list_no_of_conn_attempts_per_target= {}
     self.usercallback = None
Example #6
0
 def __init__(self):
     if FriendshipMsgHandler.__singleton:
         raise RuntimeError, "FriendshipMsgHandler is singleton"
     self.overlay_bridge = None
     self.currmsgs = {}
     self.online_fsext_peers = Set(
     )  # online peers that speak FRIENDSHIP ext
     self.peerdb = PeerDBHandler.getInstance()
     self.frienddb = FriendDBHandler.getInstance()
     self.friendshipStatistics_db = FriendshipStatisticsDBHandler.getInstance(
     )
     self.list_no_of_conn_attempts_per_target = {}
     self.usercallback = None