diff --git a/lib/index.js b/lib/index.js index f04074c..39bdeeb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -44,36 +44,42 @@ function initConductor(peer, config) { * How many bytes does a single msg ID take up */ const MSG_ID_BYTES = MsgV4.getMootID('dummy', 'dummy').length - /** * How many bytes does an average msg take up */ const ESTIMATE_MSG_SIZE = 600 // 600 bytes - /** * How many bytes should we budget for ghost msg IDs in total in the database */ const ESTIMATE_TOTAL_GHOST_BYTES = 1024 * 1024 // 1 MB - /** * How many msgs does the average 'follows' Set feed contain */ const ESTIMATE_FOLLOWS_FEED_SIZE = 300 - /** * How many msgs does the average 'block' Set feed contain */ const ESTIMATE_BLOCK_FEED_SIZE = 30 - /** * How many msgs does the average unknown feed contain */ const ESTIMATE_FEED_SIZE = 100 - + /** + * Absolute minimum acceptable maxBytes parameter + */ const MIN_MAXBYTES = 1024 // 1 kB - const MIN_RECOMMENDED_MAXBYTES = 32 * 1024 * 1024 // 32 MB - const GOOD_RECOMMENDED_MAXBYTES = 64 * 1024 * 1024 // 64 MB - const MAX_RECOMMENDED_MAXBYTES = 100 * 1024 * 1024 // 100 MB + /** + * Lower bound for somewhat acceptable maxBytes parameter + */ + const MIN_DECENT_MAXBYTES = 32 * 1024 * 1024 // 32 MB + /** + * Recommended maxBytes parameter + */ + const RECOMMENDED_MAXBYTES = 64 * 1024 * 1024 // 64 MB + /** + * Upper bound for somewhat acceptable maxBytes parameter + */ + const MAX_DECENT_MAXBYTES = 100 * 1024 * 1024 // 100 MB const debug = makeDebug('ppppp:conductor') @@ -126,9 +132,9 @@ function initConductor(peer, config) { const estimateBytesUsed = estimateMsgCount * ESTIMATE_MSG_SIZE const factor = maxBytes / estimateBytesUsed if (estimateBytesUsed > maxBytes) { - if (maxBytes < MIN_RECOMMENDED_MAXBYTES) { + if (maxBytes < MIN_DECENT_MAXBYTES) { // prettier-ignore - debug('WARNING. maxBytes is in practice too small, we recommend at least %s bytes, ideally %s bytes, and at most %s bytes', MIN_RECOMMENDED_MAXBYTES, GOOD_RECOMMENDED_MAXBYTES, MAX_RECOMMENDED_MAXBYTES) + debug('WARNING. maxBytes is in practice too small, we recommend at least %s bytes, ideally %s bytes, and at most %s bytes', MIN_DECENT_MAXBYTES, RECOMMENDED_MAXBYTES, MAX_DECENT_MAXBYTES) } else { // prettier-ignore debug('WARNING. maxBytes might be easily surpassed, you should downscale rules to %s%', (factor*100).toFixed(0)) @@ -207,9 +213,9 @@ function initConductor(peer, config) { // prettier-ignore throw new Error(`ppppp-conductor maxBytes must be at least ${MIN_MAXBYTES} bytes, got ${maxBytes}`) } - if (maxBytes > MAX_RECOMMENDED_MAXBYTES) { + if (maxBytes > MAX_DECENT_MAXBYTES) { // prettier-ignore - debug('WARNING. maxBytes is too big, we recommend at most %s bytes', MAX_RECOMMENDED_MAXBYTES) + debug('WARNING. maxBytes is too big, we recommend at most %s bytes', MAX_DECENT_MAXBYTES) } const follows = peer.set.values('follows')