Skip to content

Commit

Permalink
Merge pull request #20 from noffle/dub_cb
Browse files Browse the repository at this point in the history
Prevent double callback in getBlocks.
  • Loading branch information
dignifiedquire committed Jun 15, 2016
2 parents 68bb0c9 + 41e303a commit 26971a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ module.exports = class Bitwap {
})
}

let finished = false
const finish = (key, err, block) => {
results[key] = {
error: err,
Expand All @@ -198,7 +199,11 @@ module.exports = class Bitwap {

if (Object.keys(results).length === keys.length) {
cleanupListeners()
cb(results)

if (!finished) {
cb(results)
}
finished = true
}
}

Expand Down

0 comments on commit 26971a6

Please sign in to comment.