mirror of https://codeberg.org/pzp/pzp-goals.git
update secret-stack to 8.1
This commit is contained in:
parent
41dcb8a374
commit
aee242981f
33
lib/index.js
33
lib/index.js
|
@ -48,30 +48,6 @@ const Obz = require('obz')
|
|||
* } PurposeWithDetails
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{ db: PPPPPDB | null }} peer
|
||||
* @returns {asserts peer is { db: PPPPPDB }}
|
||||
*/
|
||||
function assertDBPlugin(peer) {
|
||||
if (!peer.db) throw new Error('"goals" plugin requires "db" plugin')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ dict: PPPPPDict | null }} peer
|
||||
* @returns {asserts peer is { dict: PPPPPDict }}
|
||||
*/
|
||||
function assertDictPlugin(peer) {
|
||||
if (!peer.dict) throw new Error('"goals" plugin requires "dict" plugin')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ set: PPPPPSet | null }} peer
|
||||
* @returns {asserts peer is { set: PPPPPSet }}
|
||||
*/
|
||||
function assertSetPlugin(peer) {
|
||||
if (!peer.set) throw new Error('"goals" plugin requires "set" plugin')
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements {Goal}
|
||||
*/
|
||||
|
@ -141,11 +117,10 @@ class GoalImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {{ db: PPPPPDB | null, dict: PPPPPDict | null, set: PPPPPSet | null }} peer
|
||||
* @param {{ db: PPPPPDB, dict: PPPPPDict, set: PPPPPSet }} peer
|
||||
* @param {unknown} config
|
||||
*/
|
||||
function initGoals(peer, config) {
|
||||
assertDBPlugin(peer)
|
||||
// Constants:
|
||||
const EMPTY_RANGE = /** @type {Range} */ ([1, 0])
|
||||
|
||||
|
@ -170,12 +145,10 @@ function initGoals(peer, config) {
|
|||
return [0, maxDepth]
|
||||
|
||||
case 'set':
|
||||
assertSetPlugin(peer)
|
||||
const minSetDepth = peer.set.minRequiredDepth(goal.id)
|
||||
return [minSetDepth, maxDepth]
|
||||
|
||||
case 'dict':
|
||||
assertDictPlugin(peer)
|
||||
const minDictDepth = peer.dict.minRequiredDepth(goal.id)
|
||||
return [minDictDepth, maxDepth]
|
||||
|
||||
|
@ -245,7 +218,6 @@ function initGoals(peer, config) {
|
|||
* @returns {PurposeWithDetails}
|
||||
*/
|
||||
function getMsgPurpose(msgID, msg) {
|
||||
assertDBPlugin(peer)
|
||||
let servesAsTrail = false
|
||||
|
||||
// Check whether this msg is a goalful root of some tangle:
|
||||
|
@ -295,14 +267,12 @@ function initGoals(peer, config) {
|
|||
// Check whether this msg is a ghost affix of some tangle:
|
||||
for (const [tangle, , , , goalType] of validTangles) {
|
||||
if (goalType === 'dict') {
|
||||
assertDictPlugin(peer)
|
||||
const span = peer.dict.getGhostSpan()
|
||||
if (peer.dict.isGhostable(msgID, tangle.id)) {
|
||||
return ['ghost', { tangleID: tangle.id, span }]
|
||||
}
|
||||
}
|
||||
if (goalType === 'set') {
|
||||
assertSetPlugin(peer)
|
||||
const span = peer.set.getGhostSpan()
|
||||
if (peer.set.isGhostable(msgID, tangle.id)) {
|
||||
return ['ghost', { tangleID: tangle.id, span }]
|
||||
|
@ -333,4 +303,5 @@ function initGoals(peer, config) {
|
|||
}
|
||||
|
||||
exports.name = 'goals'
|
||||
exports.needs = ['db', 'dict', 'set']
|
||||
exports.init = initGoals
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"prettier": "^2.6.2",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"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"
|
||||
|
|
|
@ -29,6 +29,7 @@ function createPeer(config) {
|
|||
.use(require('secret-handshake-ext/secret-stack'))
|
||||
.use(require('ppppp-db'))
|
||||
.use(require('ppppp-dict'))
|
||||
.use(require('ppppp-set'))
|
||||
.use(require('ssb-box'))
|
||||
.use(require('../lib'))
|
||||
.call(null, {
|
||||
|
|
Loading…
Reference in New Issue