There is already a list of peers per pieces being maintained - this is used for hotswapping.
Unless I'm missing something, the reservation list is not really usable for sources peer. When everything is done and we check the hash value, the reservation[piece] array is [null, null, null, ...]. Also during download, this array can contains duplicates of the same wire.
f4c16350e7644129e70c4243fc7541e9c6040f67 implements a uniquified and permanent source list. I tried to match the rest of the object construction, this means that the source list is cleared on .flush() just before checking hash.
This would lead to something like
var sources = p.sources; // save sources in case of hash-fail
var buffer = p.flush();
if (sha1(buffer) !== torrent.pieces[index]) {
...
sources.forEach(...)
}
Unless I'm missing something, the
reservation
list is not really usable for sources peer. When everything is done and we check the hash value, thereservation[piece]
array is[null, null, null, ...]
. Also during download, this array can contains duplicates of the same wire.f4c16350e7644129e70c4243fc7541e9c6040f67 implements a uniquified and permanent source list. I tried to match the rest of the object construction, this means that the source list is cleared on
.flush()
just before checking hash.This would lead to something like
in index.js, acceptable for me.