浏览代码

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 年前
父节点
当前提交
76fb776aea
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. +11
    -5
      btpd/upload.c

+ 11
- 5
btpd/upload.c 查看文件

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


BTPDQ_FOREACH(p, &m_peerq, ul_entry) { BTPDQ_FOREACH(p, &m_peerq, ul_entry) {
if (!peer_full(p) && int ok = 0;
((cm_full(p->n->tp) && p->rate_up > 0) if (!peer_full(p)) {
|| (!cm_full(p->n->tp) && p->rate_dwn > 0))) { 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].p = p;
worthy[nworthy].i = i; worthy[nworthy].i = i;
nworthy++; nworthy++;


||||||
x
 
000:0
正在加载...
取消
保存