mirror of https://codeberg.org/pzp/pzp-gc.git
update secret-stack to 8.1
This commit is contained in:
parent
e0af1c5669
commit
2809d7bb50
29
lib/index.js
29
lib/index.js
|
@ -23,30 +23,10 @@ const makeDebug = require('debug')
|
|||
*/
|
||||
|
||||
/**
|
||||
* @param {{ db: PPPPPDB | null }} peer
|
||||
* @returns {asserts peer is { db: PPPPPDB }}
|
||||
*/
|
||||
function assertDBPlugin(peer) {
|
||||
if (!peer.db) throw new Error('"gc" plugin requires "db" plugin')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ goals: PPPPPGoal | null }} peer
|
||||
* @returns {asserts peer is { goals: PPPPPGoal }}
|
||||
*/
|
||||
function assertGoalsPlugin(peer) {
|
||||
if (!peer.goals) throw new Error('"gc" plugin requires "goals" plugin')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ db: PPPPPDB | null, goals: PPPPPGoal | null }} peer
|
||||
* @param {{ db: PPPPPDB, goals: PPPPPGoal }} peer
|
||||
* @param {Config} config
|
||||
*/
|
||||
function initGC(peer, config) {
|
||||
// Assertions
|
||||
assertDBPlugin(peer)
|
||||
assertGoalsPlugin(peer)
|
||||
|
||||
// State
|
||||
const debug = makeDebug('ppppp:gc')
|
||||
let stopMonitoringLogSize = /** @type {CallableFunction | null} */ (null)
|
||||
|
@ -58,8 +38,6 @@ function initGC(peer, config) {
|
|||
* @param {CB<void>} cb
|
||||
*/
|
||||
function cleanup(cb) {
|
||||
assertDBPlugin(peer)
|
||||
assertGoalsPlugin(peer)
|
||||
debug('Cleanup started')
|
||||
const startTime = Date.now()
|
||||
|
||||
|
@ -104,7 +82,6 @@ function initGC(peer, config) {
|
|||
* @param {CB<void>} cb
|
||||
*/
|
||||
function compact(cb) {
|
||||
assertDBPlugin(peer)
|
||||
debug('Compaction started')
|
||||
const startTime = Date.now()
|
||||
peer.db.log.compact((err) => {
|
||||
|
@ -165,13 +142,10 @@ function initGC(peer, config) {
|
|||
* @param {number} maxLogBytes
|
||||
*/
|
||||
function monitorLogSize(maxLogBytes) {
|
||||
assertDBPlugin(peer)
|
||||
|
||||
/** Number of records that match roughly 1% of the max log size */
|
||||
const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes
|
||||
|
||||
function checkLogSize() {
|
||||
assertDBPlugin(peer)
|
||||
peer.db.log.stats((err, stats) => {
|
||||
if (err) return
|
||||
const percentUsed = (stats.totalBytes / maxLogBytes) * 100
|
||||
|
@ -248,4 +222,5 @@ function initGC(peer, config) {
|
|||
}
|
||||
|
||||
exports.name = 'gc'
|
||||
exports.needs = ['db', 'goals']
|
||||
exports.init = initGC
|
||||
|
|
|
@ -36,11 +36,12 @@
|
|||
"ppppp-dict": "github:staltz/ppppp-dict",
|
||||
"ppppp-goals": "github:staltz/ppppp-goals",
|
||||
"ppppp-keypair": "github:staltz/ppppp-keypair",
|
||||
"ppppp-set": "github:staltz/ppppp-set",
|
||||
"prettier": "^2.6.2",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"rimraf": "^4.4.0",
|
||||
"secret-handshake-ext": "0.0.11",
|
||||
"secret-stack": "~8.0.0",
|
||||
"secret-stack": "~8.1.0",
|
||||
"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('ppppp-goals'))
|
||||
.use(require('ssb-box'))
|
||||
.use(require('../lib'))
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
"module": "node16",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "es2021"
|
||||
"target": "es2022"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue