if( all_peers.isEmpty() ) { //no connected peers
Debug.out( "all_peers.isEmpty()" );
return null;
}
int pos = RandomUtils.nextInt( all_peers.size() ); //pick a random peer to start
for( int i=0; i < all_peers.size(); i++ ) { //ensure we only loop once
PEPeerTransport peer = (PEPeerTransport)all_peers.get( pos ); //get next potential peer
if( peer.isChokedByMe() && UnchokerUtil.isUnchokable( peer, true ) ) { //filter out peers already unchoked, and unchokable
return peer; //found the next optimistic!
}
pos++; //try next
if( pos >= all_peers.size() ) { //loop 'round if necessary
pos = 0;
}
}
Debug.out( "no optimistic-able seeding peers found" );
return null;