Developers.FiguringOutUltrapeers

From Shareaza Wiki
Jump to navigation Jump to search

Figuring Out Ultrapeers

There are a few things that make ultrapeers complicated.

  • The specified interaction is complex to begin with. LimeWire pioneered the rules programs should use to interact with ultrapeers and leaves. They are complex.
  • There are two networks going on here at the same time: Gnutella and Gnutella2. They both have two network roles, but the rules for those roles are not the same. The names aren't even the same: Gnutella has leaves and ultrappers, while Gnutella2 has leaves and hubs.
  • Shareaza doesn't keep all its ultrapeer code in one place. There is a heap of it here in CNeighboursWithConnect. There was also a lot in CShakeNeighbour. It would be better if there were one class with a name like CUltrapeer. It would contain all the logic for ultrapeers. A new developer could ignore CUltrapeers entirely when looking at the code by not following calls into that class. Removing CUltrapeer would make Shareaza a working Gnutella client like those before ultrapeers were invented.

There are two network roles: leaf and ultrapeer. Here are some things that make it more complicated:

  • Null role. Right when LimeWire invented this, there weren't any ultrapeers or leaves on the Gnutella network yet. So, they were all in a third null role. Now, pretty much the entire network has been converted over the to the ultrapeer system. But, it's still possible to encounter an old client that doesn't know about ultrapeers and is neither a leaf nor an ultrapeer.
  • Switching roles. While Shareaza is running, it can switch network roles. It can go from being a leaf to being an ultrapeer. It can later switch back to being a leaf.
  • Possible roles. It's not just important to keep track of what role a computer is in, but also what role it could take on. For instance, you might encounter a leaf that cannot become an ultrapeer. This is not exactly the same thing as a leaf that can become an ultrapeer. Neither of these are the same as an ultrapeer.
  • Custom roles. I'm not absolutely sure about this, but I think it's possible for Shareaza to be a leaf to some computers, and an ultrapeer to others. This is why there isn't a single global variable that tells what role Shareaza is in right now. It's more complicated than that.