Revision 7b86e7d9

View differences:

streaming.c
327 327
 *
328 328
 * Looks at buffermap information received about the given peer.
329 329
 */
330
int needs(struct nodeID *n, int cid){
331
  struct peer * p = nodeid_to_peer(n, 0);
332
  if (!p) return 1; // if we don't know this peer, but we assume it needs the chunk (aggressive behaviour!)
330
int needs(struct peer *n, int cid){
331
  struct peer * p = n;
333 332

  
334 333
  //dprintf("\t%s needs c%d ? :",node_addr(p->id),c->id);
335 334
  if (! p->bmap) {
......
363 362
  return 0;
364 363
}
365 364

  
366
double peerWeightReceivedfrom(struct nodeID **n){
367
  struct peer * p = nodeid_to_peer(*n, 0);
368
  if (!p) return 0;
365
double peerWeightReceivedfrom(struct peer **n){
366
  struct peer * p = *n;
369 367
  return timerisset(&p->bmap_timestamp) ? 1 : 0.1;
370 368
}
371 369

  
......
373 371
  return 1;
374 372
}
375 373

  
376
double peerWeightRtt(struct nodeID **n){
374
double peerWeightRtt(struct peer **n){
377 375
#ifdef MONL
378
  double rtt = get_rtt(*n);
376
  double rtt = get_rtt(*n->id);
379 377
  //dprintf("RTT to %s: %f\n", node_addr(p->id), rtt);
380 378
  return finite(rtt) ? 1 / (rtt + 0.005) : 1 / 1;
381 379
#else
......
415 413
    struct chunk *c;
416 414
    int chunkid = chunkID_set_get_chunk(cset_acc, i);
417 415
    c = cb_get_chunk(cb, chunkid);
418
    if (c && needs(to->id, chunkid) ) {	// we should have the chunk, and he should not have it. Although the "accept" should have been an answer to our "offer", we do some verification
416
    if (c && needs(to, chunkid) ) {	// we should have the chunk, and he should not have it. Although the "accept" should have been an answer to our "offer", we do some verification
419 417
      chunk_attributes_update_sending(c);
420 418
      res = sendChunk(to->id, c);
421 419
      if (res >= 0) {
......
516 514
  {
517 515
    size_t selectedpairs_len = 1;
518 516
    int chunkids[size];
519
    struct nodeID *nodeids[n];
517
    struct peer *nodeids[n];
520 518
    struct PeerChunk selectedpairs[1];
521 519
  
522 520
    for (i = 0;i < size; i++) chunkids[i] = (buff+i)->id;
523
    for (i = 0; i<n; i++) nodeids[i] = (neighbours+i)->id;
521
    for (i = 0; i<n; i++) nodeids[i] = (neighbours+i);
524 522
    SCHED_TYPE(SCHED_WEIGHTING, nodeids, n, chunkids, size, selectedpairs, &selectedpairs_len, SCHED_NEEDS, SCHED_PEER, SCHED_CHUNK);
525 523
  /************ /USE SCHEDULER ****************/
526 524

  
527 525
    for (i=0; i<selectedpairs_len ; i++){
528
      struct peer *p = nodeid_to_peer(selectedpairs[i].peer, 0);
526
      struct peer *p = selectedpairs[i].peer;
529 527
      struct chunk *c = cb_get_chunk(cb, selectedpairs[i].chunk);
530 528
      dprintf("\t sending chunk[%d] to ", c->id);
531 529
      dprintf("%s\n", node_addr(p->id));

Also available in: Unified diff