mirror of https://codeberg.org/pzp/pzp-sync.git
remove unnecessary wantRange() argument
This commit is contained in:
parent
7df89f3439
commit
b0d20287ce
|
@ -45,7 +45,7 @@ class Algorithm {
|
||||||
* @param {Range} remoteHaveRange
|
* @param {Range} remoteHaveRange
|
||||||
* @returns {Range}
|
* @returns {Range}
|
||||||
*/
|
*/
|
||||||
#wantAllRange(rootMsgHash, localHaveRange, remoteHaveRange) {
|
#wantAllRange(localHaveRange, remoteHaveRange) {
|
||||||
return remoteHaveRange
|
return remoteHaveRange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Algorithm {
|
||||||
* @param {number} count
|
* @param {number} count
|
||||||
* @returns {Range}
|
* @returns {Range}
|
||||||
*/
|
*/
|
||||||
#wantNewestRange(rootMsgHash, localHaveRange, remoteHaveRange, count) {
|
#wantNewestRange(localHaveRange, remoteHaveRange, count) {
|
||||||
const [minLocalHave, maxLocalHave] = localHaveRange
|
const [minLocalHave, maxLocalHave] = localHaveRange
|
||||||
const [minRemoteHave, maxRemoteHave] = remoteHaveRange
|
const [minRemoteHave, maxRemoteHave] = remoteHaveRange
|
||||||
if (maxRemoteHave <= maxLocalHave) return [1, 0]
|
if (maxRemoteHave <= maxLocalHave) return [1, 0]
|
||||||
|
@ -73,27 +73,26 @@ class Algorithm {
|
||||||
* @param {number} count
|
* @param {number} count
|
||||||
* @returns {Range}
|
* @returns {Range}
|
||||||
*/
|
*/
|
||||||
#wantOldestRange(rootMsgHash, localHaveRange, remoteHaveRange, count) {
|
#wantOldestRange(localHaveRange, remoteHaveRange, count) {
|
||||||
// FIXME:
|
// FIXME:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} rootMsgHash // FIXME: delete YAGNI
|
|
||||||
* @param {Range} localHave
|
* @param {Range} localHave
|
||||||
* @param {Range} remoteHave
|
* @param {Range} remoteHave
|
||||||
* @param {Goal?} goal
|
* @param {Goal?} goal
|
||||||
* @returns {Range}
|
* @returns {Range}
|
||||||
*/
|
*/
|
||||||
wantRange(rootMsgHash, localHave, remoteHave, goal) {
|
wantRange(localHave, remoteHave, goal) {
|
||||||
if (!goal) return [1, 0]
|
if (!goal) return [1, 0]
|
||||||
if (isEmptyRange(remoteHave)) return [1, 0]
|
if (isEmptyRange(remoteHave)) return [1, 0]
|
||||||
const { type, count } = parseGoal(goal)
|
const { type, count } = parseGoal(goal)
|
||||||
if (type === 'all') {
|
if (type === 'all') {
|
||||||
return this.#wantAllRange(rootMsgHash, localHave, remoteHave)
|
return this.#wantAllRange(localHave, remoteHave)
|
||||||
} else if (type === 'newest') {
|
} else if (type === 'newest') {
|
||||||
return this.#wantNewestRange(rootMsgHash, localHave, remoteHave, count)
|
return this.#wantNewestRange(localHave, remoteHave, count)
|
||||||
} else if (type === 'oldest') {
|
} else if (type === 'oldest') {
|
||||||
return this.#wantOldestRange(rootMsgHash, localHave, remoteHave, count)
|
return this.#wantOldestRange(localHave, remoteHave, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class SyncStream extends Pipeable {
|
||||||
this.#remoteHave.set(id, remoteHaveRange)
|
this.#remoteHave.set(id, remoteHaveRange)
|
||||||
const goal = this.#goals.get(id)
|
const goal = this.#goals.get(id)
|
||||||
const haveRange = this.#algo.haveRange(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.#localHave.set(id, haveRange)
|
||||||
this.#localWant.set(id, wantRange)
|
this.#localWant.set(id, wantRange)
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -128,7 +128,7 @@ class SyncStream extends Pipeable {
|
||||||
this.#remoteWant.set(id, remoteWantRange)
|
this.#remoteWant.set(id, remoteWantRange)
|
||||||
const goal = this.#goals.get(id)
|
const goal = this.#goals.get(id)
|
||||||
const haveRange = this.#localHave.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)
|
this.#localWant.set(id, wantRange)
|
||||||
const localBloom0 = this.#algo.bloomFor(id, 0, wantRange)
|
const localBloom0 = this.#algo.bloomFor(id, 0, wantRange)
|
||||||
this.sink.write({
|
this.sink.write({
|
||||||
|
|
Loading…
Reference in New Issue