From 20be8868724fa1089bea407e4ca28e5bb80fc597 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Thu, 12 Oct 2023 15:31:41 +0300 Subject: [PATCH] remove goal "oldest" --- lib/algorithm.js | 16 ---------------- lib/stream.js | 6 +----- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/lib/algorithm.js b/lib/algorithm.js index 61d3b96..3b94b38 100644 --- a/lib/algorithm.js +++ b/lib/algorithm.js @@ -79,17 +79,6 @@ class Algorithm { return [minWant, maxWant] } - /** - * @param {Range} localHaveRange - * @param {Range} remoteHaveRange - * @param {number} count - * @returns {Range} - */ - #wantOldestRange(localHaveRange, remoteHaveRange, count) { - // TODO: implement - throw new Error('not implemented') - } - /** * @param {Range} localHave * @param {Range} remoteHave @@ -103,8 +92,6 @@ class Algorithm { return this.#wantAllRange(localHave, remoteHave) } else if (goal.type === 'newest') { return this.#wantNewestRange(localHave, remoteHave, goal.count) - } else if (goal.type === 'oldest') { - return this.#wantOldestRange(localHave, remoteHave, goal.count) } return EMPTY_RANGE } @@ -249,9 +236,6 @@ class Algorithm { if (goal.type === 'newest') { return await this.pruneNewest(rootID, goal.count) } - if (goal.type === 'oldest') { - throw new Error('not implemented') // TODO - } } /** diff --git a/lib/stream.js b/lib/stream.js index 08d643b..e500ef5 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -7,11 +7,7 @@ const { isEmptyRange } = require('./range') * @typedef {import('ppppp-db/msg-v3').Msg} Msg * @typedef {import('./range').Range} Range * @typedef {import('./algorithm')} Algorithm - * @typedef {{ - * type: 'all' | 'newest' | 'oldest', - * count: number, - * id: string - * }} Goal + * @typedef {import('ppppp-goals').Goal} Goal * @typedef {string} MsgID * @typedef {{id: string}} WithId * @typedef {WithId & {phase: 0, payload?: undefined}} Data0