Pseudo-code is ungood, since I'm not really a good programmer. But I will try to write it mathematically.
A,B,C,D,E,F be ultrapeers
In(A)={D,E} // incoming connections
Out(A)={B,C} // outgoing connections
Out(D)=Out(E)={F}
Out(D)=Out(E)={A}
I will assume that none of those ultrapeers fails.
A will receive F from B & C, so it will save F in his hostlist with a score of 2 for example
B->A = Out(B) = Out(C) = C->A
=> Hostcache(A) = {(F,2)}
To E & F, A will send Out(A) and the top ranked hosts from his hostlist.
A->F = A->E = Out(A) U max(Hostcache(A))
=> Hostcache(E) = Hostcache(F) = {(F,1), (B,1), (C,1)}
Another example: An Ultrapeer A is having 10 incoming Ultrapeer-Connections and no outgoing connections. Let's assume that each of the nodes connected to A are having 6 connections, of which one is going out to another node connected to A, one is coming in from another node connected to A, one is going out to A, and three are coming in from other ultrapeers. That means each node connected to A is sending on A's address and the address of another host connected to A.
An Ultrapeer that has two outgoing connections to hosts which are connected to A, will receive A's address two times, that means A will quickly advance to the top of the hostcache-ranking and thus A will be propagated further throughout the network.
Let's assume A was online 24/7, so it's address would never be deleted out of the hostcaches. A leaf-servent which was connected to the network a couple of days ago for the last time but knows the address of A can now easily (without needing the gnutella host cachers/routers) connect to A. A probably won't accept further incoming connections, so it sends a deny-message to the leaf-servent. This deny-message contains the addresses of other ultrapeers (as it is implemented in the gnutella 0.6 handshake-protocol), ideally those ultrapeers it is currently connected to.
If there are more hosts like A throughout the network which everyone knows, reconnecting is almost failsafe, even without connectX.gnutellanet.com. It would be impossible to shut gnutella down. |