Skip to content

Commit

Permalink
skip read if we do not have block
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Oct 4, 2024
1 parent 1de6e6f commit 3811937
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/replicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,8 @@ module.exports = class Replicator {

const blocks = new Map()
for (const b of this._blocks) {
if (this.core.bitfield.get(b.index) === false) continue

const request = this.core.blocks.get(reader, b.index)
blocks.set(b, request)

Expand All @@ -1851,8 +1853,6 @@ module.exports = class Replicator {
reader.tryFlush()

for (const [b, request] of blocks) {
if (this.core.bitfield.get(b.index) === false) continue

try {
b.resolve(await request)
} catch (err) {
Expand Down

0 comments on commit 3811937

Please sign in to comment.