diff --git a/lib/index.js b/lib/index.js index c38da27..25345c9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -59,7 +59,7 @@ function fromSubdomain(subdomain) { * }} peer * @returns {asserts peer is { db: PPPPPDB, close: ClosableHook }} */ -function assertDBExists(peer) { +function assertDBPlugin(peer) { if (!peer.db) throw new Error('record plugin requires ppppp-db plugin') } @@ -68,7 +68,7 @@ function assertDBExists(peer) { * @param {any} config */ function initRecord(peer, config) { - assertDBExists(peer) + assertDBPlugin(peer) //#region state let accountID = /** @type {string | null} */ (null) @@ -251,7 +251,7 @@ function initRecord(peer, config) { * @returns {number} */ function _squeezePotential(subdomain) { - assertDBExists(peer) + assertDBPlugin(peer) if (!accountID) throw new Error('Cannot squeeze potential before loading') // TODO: improve this so that the squeezePotential is the size of the // tangle suffix built as a slice from the fieldRoots @@ -275,7 +275,7 @@ function initRecord(peer, config) { * @param {CB} cb */ function forceUpdate(subdomain, update, cb) { - assertDBExists(peer) + assertDBPlugin(peer) if (!accountID) throw new Error('Cannot force update before loading') const domain = fromSubdomain(subdomain) @@ -304,7 +304,7 @@ function initRecord(peer, config) { * @param {CB} cb */ function load(id, cb) { - assertDBExists(peer) + assertDBPlugin(peer) accountID = id loadPromise = new Promise((resolve, reject) => { for (const rec of peer.db.records()) { @@ -338,7 +338,7 @@ function initRecord(peer, config) { * @returns {number} */ function getMinRequiredDepth(tangleID) { - assertDBExists(peer) + assertDBPlugin(peer) const rootMsg = peer.db.get(tangleID) if (!rootMsg) throw new Error(`Cannot find tangle root "${tangleID}"`) @@ -378,7 +378,7 @@ function initRecord(peer, config) { * @returns {Record | null} */ function read(id, subdomain) { - assertDBExists(peer) + assertDBPlugin(peer) const domain = fromSubdomain(subdomain) const mootID = MsgV3.getMootID(id, domain) const tangle = peer.db.getTangle(mootID)