Skip to content

Commit

Permalink
replication factors in prologue length
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Oct 10, 2024
1 parent 9aa5859 commit 67c6a79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/merkle-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ module.exports = class MerkleTree {
this.crypto = crypto
this.fork = fork
this.roots = roots
this.length = roots.length ? totalSpan(roots) / 2 : prologue ? prologue.length : 0
this.length = roots.length ? totalSpan(roots) / 2 : 0
this.byteLength = totalSize(roots)
this.signature = signature
this.prologue = prologue
Expand Down
6 changes: 4 additions & 2 deletions lib/replicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ class Peer {
}

_requestBlock (b) {
const { length, fork } = this.core.tree
const { prologue, length, fork } = this.core.tree

if (this._remoteHasBlock(b.index) === false || fork !== this.remoteFork) {
this._maybeWant(b.index)
Expand All @@ -1200,7 +1200,9 @@ class Peer {
return false
}

const req = this._makeRequest(b.index >= length, b.priority, b.index + 1)
const treeLength = (prologue && prologue.length > length) ? prologue.length : length

const req = this._makeRequest(b.index >= treeLength, b.priority, b.index + 1)
if (req === null) return false

this._sendBlockRequest(req, b)
Expand Down

0 comments on commit 67c6a79

Please sign in to comment.