refactor msg ID bytes estimate

This commit is contained in:
Andre Staltz 2023-12-21 13:44:27 +02:00
parent bb7383aa6d
commit c2e4cea865
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
const makeDebug = require('debug')
const MsgV3 = require('ppppp-db/msg-v3')
/**
* @typedef {ReturnType<import('ppppp-db').init>} 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)