Browse Source

Peers we download from are given a weight of two compared to peers we seed to

when we decide which peers to upload to. Also fix so that we don't prefer to
upload to peers who has had a good rate but isn't uploading to us now.
master
Richard Nyberg 19 years ago
parent
commit
76fb776aea
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      btpd/upload.c

+ 11
- 5
btpd/upload.c View File

@@ -19,8 +19,8 @@ rate_cmp(const void *arg1, const void *arg2)
{
struct peer *p1 = ((struct peer_sort *)arg1)->p;
struct peer *p2 = ((struct peer_sort *)arg2)->p;
unsigned long rate1 = cm_full(p1->n->tp) ? p1->rate_up : p1->rate_dwn;
unsigned long rate2 = cm_full(p2->n->tp) ? p2->rate_up : p2->rate_dwn;
unsigned long rate1 = cm_full(p1->n->tp) ? p1->rate_up / 2: p1->rate_dwn;
unsigned long rate2 = cm_full(p2->n->tp) ? p2->rate_up / 2: p2->rate_dwn;
if (rate1 < rate2)
return -1;
else if (rate1 == rate2)
@@ -51,9 +51,15 @@ choke_do(void)
int unchoked[m_npeers];

BTPDQ_FOREACH(p, &m_peerq, ul_entry) {
if (!peer_full(p) &&
((cm_full(p->n->tp) && p->rate_up > 0)
|| (!cm_full(p->n->tp) && p->rate_dwn > 0))) {
int ok = 0;
if (!peer_full(p)) {
if (cm_full(p->n->tp)) {
if (p->rate_up > 0)
ok = 1;
} else if (peer_active_down(p) && p->rate_dwn > 0)
ok = 1;
}
if (ok) {
worthy[nworthy].p = p;
worthy[nworthy].i = i;
nworthy++;


||||||
x
 
000:0
Loading…
Cancel
Save