refactor (cosmetic)

This commit is contained in:
Andre Staltz 2023-10-26 13:28:33 +03:00
parent c7dc78b859
commit a85403dd34
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ const makeDebug = require('debug')
* @param {{ db: PPPPPDB | null }} peer * @param {{ db: PPPPPDB | null }} peer
* @returns {asserts peer is { db: PPPPPDB }} * @returns {asserts peer is { db: PPPPPDB }}
*/ */
function assertDBExists(peer) { function assertDBPlugin(peer) {
if (!peer.db) throw new Error('gc plugin requires ppppp-db plugin') if (!peer.db) throw new Error('gc plugin requires ppppp-db plugin')
} }
@ -34,7 +34,7 @@ function assertDBExists(peer) {
* @param {{ goals: PPPPPGoal | null }} peer * @param {{ goals: PPPPPGoal | null }} peer
* @returns {asserts peer is { goals: PPPPPGoal }} * @returns {asserts peer is { goals: PPPPPGoal }}
*/ */
function assertGoalsExists(peer) { function assertGoalsPlugin(peer) {
if (!peer.goals) throw new Error('gc plugin requires ppppp-goals plugin') if (!peer.goals) throw new Error('gc plugin requires ppppp-goals plugin')
} }
@ -54,8 +54,8 @@ function assertValidConfig(config) {
*/ */
function initGC(peer, config) { function initGC(peer, config) {
// Assertions // Assertions
assertDBExists(peer) assertDBPlugin(peer)
assertGoalsExists(peer) assertGoalsPlugin(peer)
assertValidConfig(config) assertValidConfig(config)
// Constants // Constants
@ -74,8 +74,8 @@ function initGC(peer, config) {
* @param {CB<void>} cb * @param {CB<void>} cb
*/ */
function cleanup(cb) { function cleanup(cb) {
assertDBExists(peer) assertDBPlugin(peer)
assertGoalsExists(peer) assertGoalsPlugin(peer)
debug('cleanup-per-purpose started') debug('cleanup-per-purpose started')
const done = multicb({ pluck: 1 }) const done = multicb({ pluck: 1 })
@ -120,7 +120,7 @@ function initGC(peer, config) {
* @param {CB<void>} cb * @param {CB<void>} cb
*/ */
function compact(waitPeriod, cb) { function compact(waitPeriod, cb) {
assertDBExists(peer) assertDBPlugin(peer)
const log = peer.db._getLog() // TODO: use public API? const log = peer.db._getLog() // TODO: use public API?
debug('compaction started') debug('compaction started')
/** @param {Error=} err */ /** @param {Error=} err */
@ -140,9 +140,9 @@ function initGC(peer, config) {
* Monitor the log size and schedule compaction and/or cleanup. * Monitor the log size and schedule compaction and/or cleanup.
*/ */
function monitorLogSize() { function monitorLogSize() {
assertDBExists(peer) assertDBPlugin(peer)
function checkLogSize() { function checkLogSize() {
assertDBExists(peer) assertDBPlugin(peer)
assertValidConfig(config) assertValidConfig(config)
peer.db.logStats((err, stats) => { peer.db.logStats((err, stats) => {
if (err) return if (err) return