View Single Post
  #3 (permalink)  
Old April 2nd, 2009
arne_bab's Avatar
arne_bab arne_bab is offline
Draketo, small dragon.
 
Join Date: May 31st, 2002
Location: Heidelberg, Germany
Posts: 1,881
arne_bab is a great assister to others; your light through the dark tunnel
Default

Currently we sort all of the Hosts we have. If a new host comes in, the list gets sorted again and the worst host gets dropped.

The sorting works like this:

We first check if the last connection failed or succeeded. If one succeeded and the other failed, the one with the failed connection gets sorted down and ultimately removed from the list if it loses against everyone.

If that check didn't show a difference, we check both hosts, if they are decent Phex' (high uptime). If one is a decent Phex host and the other one isn't, the decent Phex host wins and the other gets sorted down.

After that we compare the daily uptime and if that doesn't bring a difference, the time we last connected sucessfully.

If there is no difference with that we simply compare the GUID (close to random...).

In one sentence: If we have enough decent Phex hosts, Phex always prefers starting a connection to a decent Phex (we'll likely have to adapt this once there are more Phex' in the network, but in the current situation it's optimal). Phex does no preferencing for incoming connections.

-> https://phex.svn.sourceforge.net/svn...omparator.java

I smiled happily when I saw this algorithm for the first time, since it is so simple, yet extremely efficient.
__________________

-> put this banner into your own signature! <-
--
Erst im Spiel lebt der Mensch.
Nur ludantaj homoj vivas.
GnuFU.net - Gnutella For Users
Draketo.de - Shortstories, Poems, Music and strange Ideas.
Reply With Quote