expose log methods: stats, compact

This commit is contained in:
Andre Staltz 2023-11-23 15:49:54 +02:00
parent ac8e730b64
commit cfebe1f46c
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 5 additions and 10 deletions

View File

@ -1064,13 +1064,6 @@ function initDB(peer, config) {
} }
} }
/**
* @param {CB<{ totalBytes: number; deletedBytes: number }>} cb
*/
function logStats(cb) {
log.stats(cb)
}
return { return {
// public // public
installEncryptionFormat, installEncryptionFormat,
@ -1101,7 +1094,10 @@ function initDB(peer, config) {
getTangle, getTangle,
msgs, msgs,
records, records,
logStats, log: {
stats: log.stats.bind(log),
compact: log.compact.bind(log),
},
// internal // internal
findEncryptionFormatFor, findEncryptionFormatFor,

View File

@ -48,8 +48,7 @@ test('add()', async (t) => {
const rec = await p(peer.db.add)(inputMsg, rootID) const rec = await p(peer.db.add)(inputMsg, rootID)
assert.equal(rec.msg.data.text, 'This is the first post!') assert.equal(rec.msg.data.text, 'This is the first post!')
await p(peer.db._getLog().onDrain)() const stats = await p(peer.db.log.stats)()
const stats = await p(peer.db.logStats)()
assert.deepEqual(stats, { totalBytes: 1450, deletedBytes: 0 }) assert.deepEqual(stats, { totalBytes: 1450, deletedBytes: 0 })
await p(peer.close)(true) await p(peer.close)(true)