boolean found_decentralised = false;
boolean modified = false;
for ( int i=0;i<sets.length;i++ ){
TOTorrentAnnounceURLSet set = sets[i];
URL[] urls = set.getAnnounceURLs().clone();
for (int j=0;j<urls.length;j++){
URL u = urls[j];
if ( u != null && TorrentUtils.isDecentralised( u )){
if ( found_decentralised ){
modified = true;
urls[j] = null;
}else{
found_decentralised = true;
}
}
}
}
if ( modified ){
List<TOTorrentAnnounceURLSet> s_list = new ArrayList<TOTorrentAnnounceURLSet>();
for ( TOTorrentAnnounceURLSet set: sets ){
URL[] urls = set.getAnnounceURLs();
List<URL> u_list = new ArrayList<URL>( urls.length );
for ( URL u: urls ){
if ( u != null ){
u_list.add( u );
}
}
if ( u_list.size() > 0 ){
s_list.add( torrent.getAnnounceURLGroup().createAnnounceURLSet( u_list.toArray( new URL[ u_list.size() ])));
}
}
sets = s_list.toArray( new TOTorrentAnnounceURLSet[ s_list.size() ]);
}
}
List<TOTorrentAnnounceURLSet[]> new_sets = new ArrayList<TOTorrentAnnounceURLSet[]>();
if ( is_manual || sets.length < 2 ){
new_sets.add( sets );
}else{
List<TOTorrentAnnounceURLSet> list = new ArrayList<TOTorrentAnnounceURLSet>( Arrays.asList( sets ));
// often we have http:/xxxx/ and udp:/xxxx/ as separate groups - keep these together
while( list.size() > 0 ){
TOTorrentAnnounceURLSet set1 = list.remove(0);
boolean done = false;
URL[] urls1 = set1.getAnnounceURLs();
if ( urls1.length == 1 ){
URL url1 = urls1[0];
String prot1 = url1.getProtocol().toLowerCase();
String host1 = url1.getHost();
for (int i=0;i<list.size();i++){
TOTorrentAnnounceURLSet set2 = list.get(i);
URL[] urls2 = set2.getAnnounceURLs();
if ( urls2.length == 1 ){
URL url2 = urls2[0];