Update our internal peer list for this torrent from the tracker client
484726
def getPeersFromTracker(torrentData, infoHash)
      addPeer = Proc.new do |trackerPeer|
        peer = Peer.new(trackerPeer)
        peer.infoHash = infoHash
        torrentData.peers.add peer
        true
      end

      classifiedPeers = nil
      replaceDisconnectedPeer = Proc.new do |trackerPeer|
        classifiedPeers = ClassifiedPeers.new(torrentData.peers.all) if ! classifiedPeers
  
        if classifiedPeers.disconnectedPeers.size > 0
          torrentData.peers.delete classifiedPeers.disconnectedPeers.pop
          addPeer.call trackerPeer
          true
        else
          false
        end
      end

      trackerclient = torrentData.trackerClient 
    
      addProc = addPeer
      flipped = false
      trackerclient.peers.each do |p|
        if ! flipped && torrentData.peers.size >= @maxPeerCount
          addProc = replaceDisconnectedPeer
          flipped = true
        end
      
        # Don't treat ourself as a peer.
        next if p.id && p.id == trackerclient.peerId
            
        if ! torrentData.peers.findByAddr(p.ip, p.port)
          @logger.debug "#{QuartzTorrent.bytesToHex(torrentData.infoHash)}: Adding tracker peer #{p} to peers list"
          break if ! addProc.call(p)
        end
      end
    end
1324876
def update_source_list(self):
        
        with cd('/etc/apt'):
            sudo('mv sources.list sources.list.bak')
            put(StringIO(bigdata_conf.ubuntu_source_list_16),
                'sources.list', use_sudo=True)
            sudo('apt-get update -y --fix-missing')
515566
def update_required(srcpth, dstpth):
    

    return not os.path.exists(dstpth) or \
        os.stat(srcpth).st_mtime > os.stat(dstpth).st_mtime
503886
function PeerList() {
  this.map = new Map();
  this.ids = new Map();
  this.list = new List();
  this.load = null;
  this.inbound = 0;
  this.outbound = 0;
}
1182833
private function internalDataListUpdate()
    {
        $this->internalDataListData = $this->internalDataListUpdateData($this->internalDataListData, $this->internalDataListActions);
        $this->internalDataListActions = [];
    }
782078
private void update(Peer peer) {
		String id = peer.getId();
		Peer previous = peers.get(id);
		switch(previous.getStatus()) {
			case ACTIVE:
				timeouts.get(id).cancel(true);
				timeouts.put(id, executor.schedule(new Deactivate(id), delay, MILLISECONDS));
				break;
			case INACTIVE:
				peers.put(peer.getId(), peer);
				timeouts.get(id).cancel(true);
				timeouts.put(id, executor.schedule(new Deactivate(id), delay, MILLISECONDS));
				notifyActive(peer);
				break;
			default:
				String error = "Unexpected peer status: " + previous.getStatus();
				throw new RuntimeException(error);
		}
	}
139262
def update_trackers(self):
        
        self.posts_count = self.posts.filter(approved=True).count()
        first_post = self.posts.all().order_by('created').first()
        last_post = self.posts.filter(approved=True).order_by('-created').first()
        self.first_post = first_post
        self.last_post = last_post
        self.last_post_on = last_post.created if last_post else None
        self._simple_save()
        # Trigger the forum-level trackers update
        self.forum.update_trackers()
273932
def update(self):
        '''
        
        '''
        if self.hasproxy():
            sonarD = SonarData()
            range = 0
            data = self.proxy.getSonarData()

            sonarD.range = data.range
            sonarD.maxAngle = data.maxAngle
            sonarD.minAngle = data.minAngle
            sonarD.maxRange = data.maxRange
            sonarD.minRange = data.minRange


            self.lock.acquire()
            self.sonar = sonarD
            self.lock.release()
275222
def create(source, dest, tracker, open_trackers, comment, cache):
    """"""

    source_title = path.basename(source).replace('.', '_').replace(' ', '_')
    dest = '%s.torrent' % path.join(dest, source_title)

    click.secho('Creating torrent from %s ...' % source)

    my_torrent = Torrent.create_from(source)

    if comment:
        my_torrent.comment = comment

    urls = []

    if tracker:
        urls = tracker.split(',')

    if open_trackers:
        click.secho('Fetching an up-to-date open tracker list ...')
        try:
            urls.extend(get_open_trackers_from_remote())
        except RemoteDownloadError:
            click.secho('Failed. Using built-in open tracker list.', fg='red', err=True)
            urls.extend(get_open_trackers_from_local())

    if urls:
        my_torrent.announce_urls = urls

    my_torrent.to_file(dest)

    click.secho('Torrent file created: %s' % dest, fg='green')
    click.secho('Torrent info hash: %s' % my_torrent.info_hash, fg='blue')

    if cache:
        click.secho('Uploading to %s torrent cache service ...')
        try:
            result = upload_to_cache_server(dest)
            click.secho('Cached torrent URL: %s' % result, fg='yellow')

        except RemoteUploadError as e:
            click.secho('Failed: %s' % e, fg='red', err=True)
276988
async function list(torrentHandler, config) {
	try {
		const list = await clientTorrent.list(config.pid);
		for(const i in list) {
			torrentHandler.handle(list[i], config.pid);
		}
		torrentHandler.checkState(list, config.pid);
	} catch (error) {
		lError(`Exception ${error}`);
	}
}
254275
public void setPeerId(ByteBuffer peerId) {
    if (peerId != null) {
      this.peerId = peerId;
      this.hexPeerId = TorrentUtils.byteArrayToHexString(peerId.array());
    } else {
      this.peerId = null;
      this.hexPeerId = null;
    }
  }
43515
def update(self):
        
        super(AttachmentsViewlet, self).update()
        self.attachments_view = self.get_attachments_view()
1182385
def update_existing_peers( self, num_to_remove, peer_table=None, con=None, path=None ):
        
        
        if path is None:
            path = self.atlasdb_path

        # remove peers that are too old
        if self.last_clean_time + atlas_peer_clean_interval() < time_now():
            # remove stale peers
            log.debug("%s: revalidate old peers" % self.my_hostport)
            atlas_revalidate_peers( con=con, path=path, peer_table=peer_table )
            self.last_clean_time = time_now()

        removed = self.remove_unhealthy_peers( num_to_remove, con=con, path=path, peer_table=peer_table )

        # if they're also in the new set, remove them there too
        for peer in removed:
            if peer in self.new_peers:
                self.new_peers.remove(peer)

        return len(removed)
750790
def build_payload(self):
        '''
        
        '''
        payload = {}
        hashed_info = hashlib.sha1(tparser.bencode(self.torrent_dict['info']))
        self.hash_string = hashed_info.digest()
        self.peer_id = ('-DR' + VERSION +
                        ''.join(random.sample(ALPHANUM, 13)))
        assert len(self.peer_id) == 20
        payload['info_hash'] = self.hash_string
        payload['peer_id'] = self.peer_id
        payload['port'] = self.port
        payload['uploaded'] = 0
        payload['downloaded'] = 0
        payload['left'] = self.length
        payload['compact'] = 1
        payload['supportcrypto'] = 1
        payload['event'] = 'started'
        return payload
16654
def adjustBytesDownloaded(infoHash, adjustment)
      torrentData = @torrentData[infoHash]
      if ! torrentData
        @logger.warn "Asked to adjust uploaded bytes for a non-existent torrent #{QuartzTorrent.bytesToHex(infoHash)}"
        return
      end
      
      runInReactorThread do
        torrentData.bytesDownloaded += adjustment
        torrentData.bytesDownloadedDataOnly += adjustment
      end
    end
332339
@Override
  public void handleDiscoveredPeers(List<Peer> peers, String hexInfoHash) {

    if (peers.size() == 0) return;

    SharedTorrent torrent = torrentsStorage.getTorrent(hexInfoHash);

    if (torrent != null && torrent.isFinished()) return;

    final LoadedTorrent announceableTorrent = torrentsStorage.getLoadedTorrent(hexInfoHash);
    if (announceableTorrent == null) {
      logger.info("announceable torrent {} is not found in storage. Maybe it was removed", hexInfoHash);
      return;
    }

    if (announceableTorrent.getPieceStorage().isFinished()) return;

    logger.debug("Got {} peer(s) ({}) for {} in tracker response", new Object[]{peers.size(),
            Arrays.toString(peers.toArray()), hexInfoHash});

    Map<PeerUID, Peer> uniquePeers = new HashMap<PeerUID, Peer>();
    for (Peer peer : peers) {
      final PeerUID peerUID = new PeerUID(peer.getAddress(), hexInfoHash);
      if (uniquePeers.containsKey(peerUID)) continue;
      uniquePeers.put(peerUID, peer);
    }

    for (Map.Entry<PeerUID, Peer> e : uniquePeers.entrySet()) {

      PeerUID peerUID = e.getKey();
      Peer peer = e.getValue();
      boolean alreadyConnectedToThisPeer = peersStorage.getSharingPeer(peerUID) != null;

      if (alreadyConnectedToThisPeer) {
        logger.debug("skipping peer {}, because we already connected to this peer", peer);
        continue;
      }

      ConnectionListener connectionListener = new OutgoingConnectionListener(
              this,
              announceableTorrent.getTorrentHash(),
              peer.getIp(),
              peer.getPort());

      logger.debug("trying to connect to the peer {}", peer);

      boolean connectTaskAdded = this.myConnectionManager.offerConnect(
              new ConnectTask(peer.getIp(),
                      peer.getPort(),
                      connectionListener,
                      new SystemTimeService().now(),
                      Constants.DEFAULT_CONNECTION_TIMEOUT_MILLIS), 1, TimeUnit.SECONDS);
      if (!connectTaskAdded) {
        logger.info("can not connect to peer {}. Unable to add connect task to connection manager", peer);
      }
    }
  }
1118030
def add_peer(self, peer_addr):
        ""
        peer = connection.Peer(
                self._ident, self._dispatcher, peer_addr, backend.Socket())
        peer.start()
        self._started_peers[peer_addr] = peer