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) {
|
function initSet(peer, config) {
|
||||||
assertDBPlugin(peer)
|
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')
|
if (ghostSpan < 1) throw new Error('config.set.ghostSpan must be >= 0')
|
||||||
|
|
||||||
//#region state
|
//#region state
|
||||||
|
@ -531,6 +531,15 @@ function initSet(peer, config) {
|
||||||
return ghostSpan
|
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
|
* @param {any} subdomain
|
||||||
*/
|
*/
|
||||||
|
@ -583,6 +592,7 @@ function initSet(peer, config) {
|
||||||
getFeedID,
|
getFeedID,
|
||||||
isGhostable,
|
isGhostable,
|
||||||
getGhostSpan,
|
getGhostSpan,
|
||||||
|
setGhostSpan,
|
||||||
minGhostDepth,
|
minGhostDepth,
|
||||||
minRequiredDepth,
|
minRequiredDepth,
|
||||||
squeeze,
|
squeeze,
|
||||||
|
|
|
@ -19,7 +19,7 @@ test('setup', async (t) => {
|
||||||
peer = createPeer({
|
peer = createPeer({
|
||||||
keypair: aliceKeypair,
|
keypair: aliceKeypair,
|
||||||
db: { path: DIR },
|
db: { path: DIR },
|
||||||
set: { ghostSpan: 4 },
|
set: { ghostSpan: 40 },
|
||||||
})
|
})
|
||||||
|
|
||||||
await peer.db.loaded()
|
await peer.db.loaded()
|
||||||
|
@ -30,6 +30,7 @@ test('setup', async (t) => {
|
||||||
})
|
})
|
||||||
await p(peer.set.load)(aliceID)
|
await p(peer.set.load)(aliceID)
|
||||||
|
|
||||||
|
peer.set.setGhostSpan(4)
|
||||||
assert.equal(peer.set.getGhostSpan(), 4, 'getGhostSpan')
|
assert.equal(peer.set.getGhostSpan(), 4, 'getGhostSpan')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue