Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const removeBlock = async ({ key: k }) => {
blocksCount++
try {
const cid = Repo.utils.blockstore.keyToCid(k)
const b32 = cid.toV1().toString('base32')
if (markedSet.has(b32)) return null
const res = { cid }
try {
await repo.blocks.delete(cid)
removedBlocksCount++
} catch (err) {
res.err = new Error(`Could not delete block with CID ${cid}: ${err.message}`)
}
return res
} catch (err) {
const msg = `Could not convert block with key '${k}' to CID`
log(msg, err)
return { err: new Error(msg + `: ${err.message}`) }