[p2p-hackers] BT and localisation
Hal Finney
hal at finney.org
Thu Mar 10 17:56:09 UTC 2005
achewood at gmail.com writes:
> Is there any localisation in the peers connected to within a swarm...?
> For instance, if I'm in the US and there are peers spread around the
> world, am I any more likely to get data from other peers in the US
> than peers in, say, Japan or China?
The tracker code itself doesn't do this, at least not the official
BT python version:
cache = self.cache2.setdefault(infohash, [])
if len(cache) < rsize:
del cache[:]
cache.extend(self.becache2.setdefault(infohash, {}).values())
shuffle(cache)
del self.cache1.get(infohash, [])[:]
data['peers'] = ''.join(cache[-rsize:])
del cache[-rsize:]
This basically copies all the peers it knows about from becache2 to
cache2 (which is pointed to by cache). It then randomly shuffles
cache2 and returns the last 'rsize' elements, deleting them from cache2.
(rsize is the number of peers requested to be returned by the tracker.)
The next call again returns and deletes the last rsize elements from
cache2, until we have fewer than rsize elements in cache2. At that
point it is cleared and we again copy all the known peers from becache2.
This is very straightforward and makes no attempt to enforce localization.
However as others point out, you may get better bandwidth to nearby peers
and the self-reinforcing nature of the network would tend to emphasize
those links.
HF
More information about the P2p-hackers
mailing list