From c2e4cea865392231cf9f933767a65aa181d42069 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Thu, 21 Dec 2023 13:44:27 +0200 Subject: [PATCH] refactor msg ID bytes estimate --- lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 8187706..325c3a7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,5 @@ const makeDebug = require('debug') +const MsgV3 = require('ppppp-db/msg-v3') /** * @typedef {ReturnType} PPPPPDB @@ -86,7 +87,7 @@ function initConductor(peer, config) { assertSyncPlugin(peer) const ESTIMATE_TOTAL_GHOST_BYTES = 1024 * 1024 // 1 MB - const ESTIMATE_MSG_ID_BYTES = 22 // 22 bytes per msg ID + const MSG_ID_BYTES = MsgV3.getMootID('dummy', 'dummy').length const debug = makeDebug('ppppp:conductor') @@ -210,7 +211,7 @@ function initConductor(peer, config) { const totalGhostableFeeds = countGhostableFeeds(myRules) + followedAccounts.length * countGhostableFeeds(theirRules) - const TOTAL_GHOSTS = ESTIMATE_TOTAL_GHOST_BYTES / ESTIMATE_MSG_ID_BYTES + const TOTAL_GHOSTS = ESTIMATE_TOTAL_GHOST_BYTES / MSG_ID_BYTES const ghostSpan = Math.round(TOTAL_GHOSTS / totalGhostableFeeds) peer.set.setGhostSpan(ghostSpan) peer.dict?.setGhostSpan(ghostSpan)