refactor: rename some assert functions

This commit is contained in:
Andre Staltz 2023-10-18 17:10:29 +03:00
parent 1b32169541
commit 3f73dada5b
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 5 additions and 5 deletions

View File

@ -30,7 +30,7 @@ const Obz = require('obz')
* @param {{ db: PPPPPDB | null }} peer
* @returns {asserts peer is { db: PPPPPDB }}
*/
function assertDBExists(peer) {
function assertDBPlugin(peer) {
if (!peer.db) throw new Error('goals plugin requires ppppp-db plugin')
}
@ -38,7 +38,7 @@ function assertDBExists(peer) {
* @param {{ record: PPPPPRecord | null }} peer
* @returns {asserts peer is { record: PPPPPRecord }}
*/
function assertRecordExists(peer) {
function assertRecordPlugin(peer) {
if (!peer.record) throw new Error('goals plugin requires ppppp-record plugin')
}
@ -115,7 +115,7 @@ class GoalImpl {
* @param {unknown} config
*/
function initGoals(peer, config) {
assertDBExists(peer)
assertDBPlugin(peer)
// Constants:
const EMPTY_RANGE = /** @type {Range} */ ([1, 0])
@ -138,7 +138,7 @@ function initGoals(peer, config) {
case 'set':
return [0, maxDepth]
case 'record':
assertRecordExists(peer)
assertRecordPlugin(peer)
const minDepth = peer.record.getMinRequiredDepth(goal.id)
return [minDepth, maxDepth]
case 'newest':
@ -174,7 +174,7 @@ function initGoals(peer, config) {
* @returns {Purpose}
*/
function getRecordPurpose(rec) {
assertDBExists(peer)
assertDBPlugin(peer)
let servesAsTrail = false
// Check whether this record is a goalful root of some tangle: