Skip to content

Instantly share code, notes, and snippets.

@flimshaw
Created September 20, 2016 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flimshaw/13062016f8da38e94a50ca8bb393ef4d to your computer and use it in GitHub Desktop.
Save flimshaw/13062016f8da38e94a50ca8bb393ef4d to your computer and use it in GitHub Desktop.
if(this.chunkCounter > this.torrent.pieces.length) {
this.chunkCounter = 0;
this.loading = false;
}
if(this.torrent.store.store.chunks[this.chunkCounter] !== undefined && this.torrent.pieces[this.chunkCounter] === null) {
let a = this.torrent.store.store.chunks[this.chunkCounter];
// fire off an anon function that contains a reference to the chunk id we're sending
// probably shoudl be a promise someday
(() => {
var cc = Math.floor(this.chunkCounter);
this.torrent.store.get(cc, (err, data) => {
if(err) {
console.log("Torrent error: ", err);
}
view.queueUpdate(data, cc*this.chunkSize, data.length, this.chunkCounter )
})
this.chunkCounter++;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment