Skip to content

Commit 9052e51

Browse files
committed
Use BitInterlude's ranges when broadcasting to peers in _verifyShared()
1 parent 5713481 commit 9052e51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/core.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,12 @@ module.exports = class Core {
458458
if (batch.commitable()) batch.commit(tx)
459459
}
460460

461-
bits.flush(tx, this.replicator.localBitfield)
461+
const ranges = bits.flush(tx, this.replicator.localBitfield)
462462

463463
await this.state.flush()
464464

465-
for (let i = 0; i < verifies.length; i++) {
466-
const bitfield = verifies[i] && verifies[i].bitfield
467-
if (bitfield) {
468-
this.replicator.onhave(bitfield.start, bitfield.length, bitfield.drop)
469-
}
465+
for (const range of ranges) {
466+
this.replicator.onhave(range.start, range.end - range.start, !range.value)
470467
}
471468
} finally {
472469
this.state._clearActiveBatch()

0 commit comments

Comments
 (0)