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