mirror of https://codeberg.org/pzp/pzp-set.git
setGhostSpan
This commit is contained in:
parent
c4faaf27ce
commit
39b3364137
12
lib/index.js
12
lib/index.js
|
@ -90,7 +90,7 @@ function assert(check, message) {
|
|||
function initSet(peer, config) {
|
||||
assertDBPlugin(peer)
|
||||
|
||||
const ghostSpan = config.set?.ghostSpan ?? 32
|
||||
let ghostSpan = config.set?.ghostSpan ?? 32
|
||||
if (ghostSpan < 1) throw new Error('config.set.ghostSpan must be >= 0')
|
||||
|
||||
//#region state
|
||||
|
@ -531,6 +531,15 @@ function initSet(peer, config) {
|
|||
return ghostSpan
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} span
|
||||
* @returns {void}
|
||||
*/
|
||||
function setGhostSpan(span) {
|
||||
if (span < 1) throw new Error('ghostSpan must be >= 0')
|
||||
ghostSpan = span
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} subdomain
|
||||
*/
|
||||
|
@ -583,6 +592,7 @@ function initSet(peer, config) {
|
|||
getFeedID,
|
||||
isGhostable,
|
||||
getGhostSpan,
|
||||
setGhostSpan,
|
||||
minGhostDepth,
|
||||
minRequiredDepth,
|
||||
squeeze,
|
||||
|
|
|
@ -19,7 +19,7 @@ test('setup', async (t) => {
|
|||
peer = createPeer({
|
||||
keypair: aliceKeypair,
|
||||
db: { path: DIR },
|
||||
set: { ghostSpan: 4 },
|
||||
set: { ghostSpan: 40 },
|
||||
})
|
||||
|
||||
await peer.db.loaded()
|
||||
|
@ -30,6 +30,7 @@ test('setup', async (t) => {
|
|||
})
|
||||
await p(peer.set.load)(aliceID)
|
||||
|
||||
peer.set.setGhostSpan(4)
|
||||
assert.equal(peer.set.getGhostSpan(), 4, 'getGhostSpan')
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue