Developers.Code.CNeighboursWithED2K

From Shareaza Wiki
Revision as of 18:16, 31 December 2007 by Dirtycat (talk | contribs) (Importing page from Tikiwiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

CNeighboursWithED2K

When Shareaza runs, it makes one CNeighbours object. The object keeps the list of open connections to remote computers on the Internet running compatible peer-to-peer software. The class CNeighboursWithG1 adds Gnutella-specific functionality to the CNeighbours object. Anything related to Gnutella that needs access to the neighbours list goes here. CNeighboursWithG2 does the same thing for Gnutella2. Likewise, CNeighboursWithED2K is where eDonkey code accesses the neighbours list.

Methods

GetDonkeyServer looks in the neighbours list for an eDonkey2000 computer that we've finished the handshake with and that has a client ID. When it finds one, it returns it. CloseDonkeys just loops down the list, calling Close on each eDonkey2000 computer. SendDonkeyDownload takes a pointer to a CDownload object. It tells each connected eDonkey2000 computer about it.

PushDonkey and FindDonkeySources send eDonkey2000 packets. FindDonkeySources uses 2 arrays that CNeighboursWithED2K adds to CNeighbours.

<source lang="c"> // Hash arrays used by FindDonkeySources DWORD m_tEDSources[256]; // 256 MD4 hashes MD4 m_pEDSources[256]; // The tick counts when these array spots were filled or looked at </source>

Refactoring

The methods here will make more sense when I'm commenting and documenting the eDonkey2000 network. Ideally, the code specific to each network would be located in one place and separated from the other networks. The current design of CNeighbours keeps code that access the neighbours list separate, and slices through all the networks to do it.