diff --git a/lib/algorithm.js b/lib/algorithm.js index 625e7f8..e5a83ad 100644 --- a/lib/algorithm.js +++ b/lib/algorithm.js @@ -45,7 +45,7 @@ class Algorithm { * @param {Range} remoteHaveRange * @returns {Range} */ - #wantAllRange(rootMsgHash, localHaveRange, remoteHaveRange) { + #wantAllRange(localHaveRange, remoteHaveRange) { return remoteHaveRange } @@ -56,7 +56,7 @@ class Algorithm { * @param {number} count * @returns {Range} */ - #wantNewestRange(rootMsgHash, localHaveRange, remoteHaveRange, count) { + #wantNewestRange(localHaveRange, remoteHaveRange, count) { const [minLocalHave, maxLocalHave] = localHaveRange const [minRemoteHave, maxRemoteHave] = remoteHaveRange if (maxRemoteHave <= maxLocalHave) return [1, 0] @@ -73,27 +73,26 @@ class Algorithm { * @param {number} count * @returns {Range} */ - #wantOldestRange(rootMsgHash, localHaveRange, remoteHaveRange, count) { + #wantOldestRange(localHaveRange, remoteHaveRange, count) { // FIXME: } /** - * @param {string} rootMsgHash // FIXME: delete YAGNI * @param {Range} localHave * @param {Range} remoteHave * @param {Goal?} goal * @returns {Range} */ - wantRange(rootMsgHash, localHave, remoteHave, goal) { + wantRange(localHave, remoteHave, goal) { if (!goal) return [1, 0] if (isEmptyRange(remoteHave)) return [1, 0] const { type, count } = parseGoal(goal) if (type === 'all') { - return this.#wantAllRange(rootMsgHash, localHave, remoteHave) + return this.#wantAllRange(localHave, remoteHave) } else if (type === 'newest') { - return this.#wantNewestRange(rootMsgHash, localHave, remoteHave, count) + return this.#wantNewestRange(localHave, remoteHave, count) } else if (type === 'oldest') { - return this.#wantOldestRange(rootMsgHash, localHave, remoteHave, count) + return this.#wantOldestRange(localHave, remoteHave, count) } } diff --git a/lib/stream.js b/lib/stream.js index bb64f61..9be419b 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -113,7 +113,7 @@ class SyncStream extends Pipeable { this.#remoteHave.set(id, remoteHaveRange) const goal = this.#goals.get(id) const haveRange = this.#algo.haveRange(id) - const wantRange = this.#algo.wantRange(id, haveRange, remoteHaveRange, goal) + const wantRange = this.#algo.wantRange(haveRange, remoteHaveRange, goal) this.#localHave.set(id, haveRange) this.#localWant.set(id, wantRange) // prettier-ignore @@ -128,7 +128,7 @@ class SyncStream extends Pipeable { this.#remoteWant.set(id, remoteWantRange) const goal = this.#goals.get(id) const haveRange = this.#localHave.get(id) - const wantRange = this.#algo.wantRange(id, haveRange, remoteHaveRange, goal) + const wantRange = this.#algo.wantRange(haveRange, remoteHaveRange, goal) this.#localWant.set(id, wantRange) const localBloom0 = this.#algo.bloomFor(id, 0, wantRange) this.sink.write({