update secret-stack to 8.1

This commit is contained in:
Andre Staltz 2024-01-08 11:23:23 +02:00
parent 32a51697e4
commit 7fb5a0f107
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
3 changed files with 4 additions and 23 deletions

View File

@ -60,23 +60,10 @@ function fromSubdomain(subdomain) {
}
/**
* @param {{
* db: PPPPPDB | null,
* close: ClosableHook,
* }} peer
* @returns {asserts peer is { db: PPPPPDB, close: ClosableHook }}
*/
function assertDBPlugin(peer) {
if (!peer.db) throw new Error('"dict" plugin requires "db" plugin')
}
/**
* @param {{ db: PPPPPDB | null, close: ClosableHook }} peer
* @param {{ db: PPPPPDB, close: ClosableHook }} peer
* @param {Config} config
*/
function initDict(peer, config) {
assertDBPlugin(peer)
let ghostSpan = config.dict?.ghostSpan ?? 32
if (ghostSpan < 1) throw new Error('config.dict.ghostSpan must be >= 0')
@ -261,7 +248,6 @@ function initDict(peer, config) {
* @returns {number}
*/
function _squeezePotential(subdomain) {
assertDBPlugin(peer)
// prettier-ignore
if (!loadedAccountID) throw new Error('Cannot squeeze potential before loading')
// TODO: improve this so that the squeezePotential is the size of the
@ -286,7 +272,6 @@ function initDict(peer, config) {
* @param {CB<boolean>} cb
*/
function forceUpdate(subdomain, update, cb) {
assertDBPlugin(peer)
if (!loadedAccountID) throw new Error('Cannot force update before loading')
const domain = fromSubdomain(subdomain)
@ -315,7 +300,6 @@ function initDict(peer, config) {
* @param {CB<void>} cb
*/
function load(accountID, cb) {
assertDBPlugin(peer)
if (accountID === loadedAccountID) {
loaded(cb)
return
@ -365,7 +349,6 @@ function initDict(peer, config) {
* @returns {number}
*/
function minRequiredDepth(tangleID) {
assertDBPlugin(peer)
const tangle = peer.db.getTangle(tangleID)
// prettier-ignore
@ -414,7 +397,6 @@ function initDict(peer, config) {
* @returns {{[field in string]: any} | null}
*/
function read(id, subdomain) {
assertDBPlugin(peer)
const domain = fromSubdomain(subdomain)
const mootID = MsgV4.getMootID(id, domain)
const tangle = peer.db.getTangle(mootID)
@ -441,7 +423,6 @@ function initDict(peer, config) {
*/
function getFeedID(subdomain) {
if (!loadedAccountID) throw new Error('Cannot getFeedID() before loading')
assertDBPlugin(peer)
const domain = fromSubdomain(subdomain)
return MsgV4.getMootID(loadedAccountID, domain)
}
@ -454,7 +435,6 @@ function initDict(peer, config) {
function isGhostable(ghostableMsgID, tangleID) {
if (ghostableMsgID === tangleID) return false
assertDBPlugin(peer)
const msg = peer.db.get(ghostableMsgID)
// prettier-ignore
@ -554,4 +534,5 @@ function initDict(peer, config) {
}
exports.name = 'dict'
exports.needs = ['db']
exports.init = initDict

View File

@ -33,7 +33,7 @@
"ppppp-caps": "github:staltz/ppppp-caps",
"ppppp-keypair": "github:staltz/ppppp-keypair",
"rimraf": "^4.4.0",
"secret-stack": "~8.0.0",
"secret-stack": "~8.1.0",
"secret-handshake-ext": "0.0.10",
"ssb-box": "^1.0.1",
"typescript": "^5.1.3"

View File

@ -11,6 +11,6 @@
"module": "node16",
"skipLibCheck": true,
"strict": true,
"target": "es2021"
"target": "es2022"
}
}