Skip to content

Commit

Permalink
fix(BlockStream): fix bug where the last block in a stream was not re…
Browse files Browse the repository at this point in the history
…quested, so stream never ended
  • Loading branch information
mappum committed Jan 14, 2016
1 parent 812e828 commit 76f04f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/blockStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ BlockStream.prototype._next = function () {
var hash = u.toHash(block.header.hash)
if (self.requestHeight == null) self.requestHeight = block.height + 1
self.requestQueue.push(hash)
self._getData(block)
if (!block.next) {
return self.requestQueue.push(null)
}
self.requestCursor = u.toHash(block.next)
self._getData(block)
if (self.pause || self.requestQueue.length >= self.bufferSize) return
self._next()
})
Expand Down Expand Up @@ -165,5 +165,5 @@ BlockStream.prototype._push = function (i, data) {
var more = this.push(head)
if (!more) this.pause = true
}
if (this.buffer[0] === null) this.push(null)
if (this.requestQueue[0] === null) this.push(null)
}

0 comments on commit 76f04f0

Please sign in to comment.