Skip to content

Commit

Permalink
check bitfield before deciding to wait
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Sep 17, 2024
1 parent cf41c44 commit 3b89c34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,15 @@ module.exports = class Hypercore extends EventEmitter {
if (coreBlock !== null) return coreBlock
}

if (this.core.state.bitfield.get(index)) {
return readBlock(this.state.createReadBatch(), index)
}

if (!this._shouldWait(opts, this.wait)) return null

if (opts && opts.onwait) opts.onwait(index, this)
if (this.onwait) this.onwait(index, this)

if (this.core.state.bitfield.get(index)) {
return readBlock(this.state.createReadBatch(), index)
}

const activeRequests = (opts && opts.activeRequests) || this.activeRequests

const req = this.replicator.addBlock(activeRequests, index)
Expand Down

0 comments on commit 3b89c34

Please sign in to comment.