Skip to content

Commit

Permalink
tests all pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Jun 11, 2024
1 parent 8be83a0 commit d3f74d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/encrypted-blockstore/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,23 +331,23 @@ export class Loader implements Loadable {
let splitcount = Math.ceil(size / threshold)
let splitpercount = Math.floor(count / splitcount)
let newcount = 0
let clonedt = new CarTransaction(t.parent)
let clonedt = new CarTransaction(t.parent, { add: false })
for (const { cid, bytes } of t.entries()) {
newcount++
clonedt.putSync(cid, bytes)
if (newcount >= splitpercount) {
const carFile =
theKey && this.ebOpts.crypto
? await encryptedEncodeCarFile(
this.ebOpts.crypto,
theKey,
roots[0],
clonedt
)
this.ebOpts.crypto,
theKey,
roots[0],
clonedt
)
: await encodeCarFile([roots[0]], clonedt)
carFiles.push(carFile)
clonedt = new CarTransaction(t.parent)
newcount=0
clonedt = new CarTransaction(t.parent, { add: false })
newcount = 0
}
}
return carFiles
Expand Down
6 changes: 4 additions & 2 deletions packages/encrypted-blockstore/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export type TransactionMeta = TM

export class CarTransaction extends MemoryBlockstore implements CarMakeable {
parent: EncryptedBlockstore
constructor(parent: EncryptedBlockstore) {
constructor(parent: EncryptedBlockstore, opts = { add: true }) {
super()
parent.transactions.add(this)
if (opts.add) {
parent.transactions.add(this)
}
this.parent = parent
}

Expand Down

0 comments on commit d3f74d2

Please sign in to comment.