refactor msg ID bytes estimate
This commit is contained in:
parent
bb7383aa6d
commit
c2e4cea865
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue