Revision c76dd2cb

View differences:

overlay.c
122 122
				peers[n].latest_not_needed = -1; //CACHE latest_not_needed
123 123
			}
124 124
			peers[n].id = n;
125
			peers[n].offer_rate = matrix_element_get(offers, n, 0);
125
			peers[n].offer_rate = 1.0/matrix_element_get(offers, n, 0);
126 126
			//fprintf(stderr, "[DEBUG] offer_rate: %f\n", matrix_element_get(offers, n, 0));
127 127
			overlay_matrix_set_neighbourhood(A, peers, n);
128 128
		}
......
130 130
		(*npeers) -= 1; // we take off one peer to be used as source
131 131
		memmove(source, &(peers[*npeers]), sizeof(struct peer));
132 132
		source->id = -1;
133
		source_set(source->neighbour, source->neigh_size, nchunks);
133
		source_set(source->neighbour, source->neigh_size, source->neighbour_prob,  nchunks);
134 134
		matrix_destroy(&A);
135 135
		matrix_destroy(&offers);
136 136
	}
......
170 170
        peers[n].latest_not_needed = -1; //CACHE latest_not_needed
171 171
      }
172 172
      peers[n].id = n;
173
      peers[n].offer_rate = 1;
173 174
      peers[n].neighbour = neighbourhood_generate(*neigh_size, peers, *npeers, n);
175
      peers[n].neighbour_prob = malloc((*neigh_size) *sizeof(double));
176
      for(c = 0; c < *neigh_size; c++)
177
      {
178
	      (peers[n].neighbour_prob)[c] = 1.0/(*neigh_size);
179
	//fprintf(stderr, "[DEBUG]: loading prob for peer %d -> %f\n", peers[n].id, (peers[n].neighbour_prob)[c]);
180
      }
174 181
      peers[n].neigh_size = *neigh_size;
175 182
    }
176 183
    source->neighbour = neighbourhood_generate(*neigh_size, peers, *npeers, -1);
177 184
    source->neigh_size = *neigh_size;
178
    source_set(source->neighbour, source->neigh_size, nchunks);
185
    source->neighbour_prob = malloc((*neigh_size) *sizeof(double));
186
    for(c = 0; c < *neigh_size; c++)
187
    {
188
	    (source->neighbour_prob)[c] = 1.0/(*neigh_size);
189
	//fprintf(stderr, "[DEBUG]: loading prob for source %d -> %f\n", source->id, (source->neighbour_prob)[c]);
190
    }
191
    source_set(source->neighbour, source->neigh_size, source->neighbour_prob,  nchunks);
179 192
    return peers;
180 193
}

Also available in: Unified diff