Created
September 20, 2016 22:08
-
-
Save flimshaw/13062016f8da38e94a50ca8bb393ef4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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