1.0.0 • Published 12 months ago
hypercore-audit v1.0.0
hypercore-audit
Audit a hypercore's storage
Usage
const core = new Hypercore(dir)
const report = await audit(core.state.storage, { dryRun: true })
console.log(report)
// {
// treeNodes: 247,
// blocks: 127,
// bits: 127,
// droppedTreeNodes: 0,
// droppedBlocks: 0,
// droppedBits: 0,
// corrupt: false
// }API
audit(storage, { tree = true, blocks = true, bitfield = true, dryRun = false }
Perform an audit on the storage instance. tree, bitfield and blocks are booleans to specify which components should be checked.
If dryRun is set to false, then any storage discrepancies will be cleaned up and the corrections will be written to the database. NOTE: this is a destructive operation
A report is returned of the form:
{
treeNodes: 247, // number of valid treeNodes present
blocks: 127, // number of valid blocks present
bits: 127, // number of valid blocks present
droppedTreeNodes: 0, // number of invalid tree nodes
droppedBlocks: 0, // number of invalid blocks
droppedBits: 0, // number of invalid bits
corrupt: false // a core is corrupt if any root nodes are missing
}License
Apache-2.0
1.0.0
12 months ago