@Nullable protected Peer selectDownloadPeer(List<Peer> peers){
  if (peers.isEmpty())   return null;
  int mostCommonChainHeight=getMostCommonChainHeight(peers);
  List<Peer> candidates=new ArrayList<Peer>();
  for (  Peer peer : peers) {
    if (peer.getBestHeight() == mostCommonChainHeight)     candidates.add(peer);
  }
  int highestVersion=0, preferredVersion=0;
  final int PREFERRED_VERSION=params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER);
  for (  Peer peer : candidates) {
    highestVersion=Math.max(peer.getPeerVersionMessage().clientVersion,highestVersion);
    preferredVersion=Math.min(highestVersion,PREFERRED_VERSION);
  }
  ArrayList<Peer> candidates2=new ArrayList<Peer>(candidates.size());
  for (  Peer peer : candidates) {
    if (peer.getPeerVersionMessage().clientVersion >= preferredVersion) {
      candidates2.add(peer);
    }
  }
  int index=(int)(Math.random() * candidates2.size());
  return candidates2.get(index);
}

@ Nullable protected Peer selectDownloadPeer ( List < Peer > peers ) { if ( peers . isEmpty ( ) ) return null ; int mostCommonChainHeight = getMostCommonChainHeight ( peers ) ; List < Peer > candidates = new ArrayList < Peer > ( ) ; for ( Peer peer : peers ) { if ( peer . getBestHeight ( ) == mostCommonChainHeight ) candidates . add ( peer ) ; } int highestVersion = 0 , preferredVersion = 0 ; final int PREFERRED_VERSION = params . getProtocolVersionNum ( NetworkParameters . ProtocolVersion . BLOOM_FILTER ) ; for ( Peer peer : candidates ) { highestVersion = Math . max ( peer . getPeerVersionMessage ( ) . clientVersion , highestVersion ) ; preferredVersion = Math . min ( highestVersion , PREFERRED_VERSION ) ; } ArrayList < Peer > candidates2 = new ArrayList < Peer > ( candidates . size ( ) ) ; for ( Peer peer : candidates ) { if ( peer . getPeerVersionMessage ( ) . clientVersion >= preferredVersion ) { candidates2 . add ( peer ) ; } } int index = ( int ) ( Math . random ( ) * candidates2 . size ( ) ) ; return candidates2 . get ( index ) ; }
given a list of peers , return a peer to be used as the download peer . if you don ' t want peergroup to manage download peer statuses for you , just override this and always return null .
