diff --git a/lib/algorithm.js b/lib/algorithm.js index 18ffa41..c6e3765 100644 --- a/lib/algorithm.js +++ b/lib/algorithm.js @@ -1,6 +1,6 @@ const p = require('promisify-4loc') const { BloomFilter } = require('bloom-filters') -const MsgV3 = require('ppppp-db/msg-v3') +const MsgV4 = require('ppppp-db/msg-v4') const makeDebug = require('debug') const debug = makeDebug('ppppp:sync') const { EMPTY_RANGE, isEmptyRange, estimateMsgCount } = require('./range') @@ -9,7 +9,7 @@ const { EMPTY_RANGE, isEmptyRange, estimateMsgCount } = require('./range') * @typedef {ReturnType} PPPPPDB * @typedef {ReturnType} PPPPPDict * @typedef {ReturnType} PPPPPSet - * @typedef {import('ppppp-db/msg-v3').Msg} Msg + * @typedef {import('ppppp-db/msg-v4').Msg} Msg * @typedef {import('ppppp-goals').Goal} Goal * @typedef {import('./range').Range} Range * @typedef {string} MsgID @@ -191,7 +191,7 @@ class Algorithm { const rangeMsgs = this.getMsgsInRange(rootID, range) const accountMsgs = this.getAccountMsgsFor(rangeMsgs) for (const msg of accountMsgs.concat(rangeMsgs)) { - filter.add('' + round + MsgV3.getMsgID(msg)) + filter.add('' + round + MsgV4.getMsgID(msg)) } } const ghosts = this.#peer.db.ghosts.get(rootID) @@ -227,7 +227,7 @@ class Algorithm { const rangeMsgs = this.getMsgsInRange(rootID, range) const accountMsgs = this.getAccountMsgsFor(rangeMsgs) for (const msg of accountMsgs.concat(rangeMsgs)) { - const msgID = MsgV3.getMsgID(msg) + const msgID = MsgV4.getMsgID(msg) if (!remoteFilter.has('' + round + msgID)) { missing.push(msgID) } @@ -245,7 +245,7 @@ class Algorithm { getAccountMsgsFor(msgs) { const accountTips = /** @type {Map>} */ (new Map()) for (const msg of msgs) { - if (MsgV3.isFeedMsg(msg)) { + if (MsgV4.isFeedMsg(msg)) { const set = accountTips.get(msg.metadata.account) ?? new Set() for (const tip of msg.metadata.accountTips) { set.add(tip) @@ -319,7 +319,7 @@ class Algorithm { if (Array.isArray(msgs) && msgs.length === 0) return [] if (!Array.isArray(msgs) && msgs.size === 0) return [] const msgIDs = [...msgs].map((m) => - typeof m === 'string' ? m : MsgV3.getMsgID(m) + typeof m === 'string' ? m : MsgV4.getMsgID(m) ) const tangle = this.#peer.db.getTangle(rootID) return tangle.slice(msgIDs, []) @@ -365,7 +365,7 @@ class Algorithm { .filter((msg) => { if (msg.metadata.account === 'self') return true const depth = msg.metadata.tangles[rootID]?.depth ?? 0 - if (depth === 0 && MsgV3.getMsgID(msg) !== rootID) { + if (depth === 0 && MsgV4.getMsgID(msg) !== rootID) { return false // the rootMsg is the only acceptable depth-zero msg } if (!msg.data) { diff --git a/lib/stream.js b/lib/stream.js index 2ec7cb4..2433dd1 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -4,7 +4,7 @@ const { isEmptyRange } = require('./range') /** * @typedef {ReturnType} PPPPPGoals - * @typedef {import('ppppp-db/msg-v3').Msg} Msg + * @typedef {import('ppppp-db/msg-v4').Msg} Msg * @typedef {import('./range').Range} Range * @typedef {import('./algorithm')} Algorithm * @typedef {import('ppppp-goals').Goal} Goal diff --git a/test/dict-sync.test.js b/test/dict-sync.test.js index d709f64..b44c276 100644 --- a/test/dict-sync.test.js +++ b/test/dict-sync.test.js @@ -2,7 +2,7 @@ const test = require('node:test') const assert = require('node:assert') const p = require('node:util').promisify const Keypair = require('ppppp-keypair') -const MsgV3 = require('ppppp-db/msg-v3') +const MsgV4 = require('ppppp-db/msg-v4') const { createPeer } = require('./util') const aliceKeypair = Keypair.generate('ed25519', 'alice') @@ -67,10 +67,10 @@ test('sync goal=dict with ghostSpan=2', async (t) => { // Bob knows a branched off msg that Alice doesn't know { - const tangle = new MsgV3.Tangle(moot.id) + const tangle = new MsgV4.Tangle(moot.id) tangle.add(moot.id, moot.msg) tangle.add(rec1.id, rec1.msg) - const msg = MsgV3.create({ + const msg = MsgV4.create({ keypair: aliceKeypair, domain: 'dict_v1__profile', account: aliceID, diff --git a/test/set-sync.test.js b/test/set-sync.test.js index 4d601b6..04e0406 100644 --- a/test/set-sync.test.js +++ b/test/set-sync.test.js @@ -2,7 +2,7 @@ const test = require('node:test') const assert = require('node:assert') const p = require('node:util').promisify const Keypair = require('ppppp-keypair') -const MsgV3 = require('ppppp-db/msg-v3') +const MsgV4 = require('ppppp-db/msg-v4') const { createPeer } = require('./util') const aliceKeypair = Keypair.generate('ed25519', 'alice') @@ -79,10 +79,10 @@ test('sync goal=set with ghostSpan=2', async (t) => { // Bob knows a branched off msg that Alice doesn't know { - const tangle = new MsgV3.Tangle(moot.id) + const tangle = new MsgV4.Tangle(moot.id) tangle.add(moot.id, moot.msg) tangle.add(rec1.id, rec1.msg) - const msg = MsgV3.create({ + const msg = MsgV4.create({ keypair: aliceKeypair, domain: 'set_v1__follows', account: aliceID,