From d3f74d2105d3298d22b221a2adc79822a95ee277 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Tue, 11 Jun 2024 16:48:12 -0700 Subject: [PATCH] tests all pass --- packages/encrypted-blockstore/src/loader.ts | 16 ++++++++-------- packages/encrypted-blockstore/src/transaction.ts | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/encrypted-blockstore/src/loader.ts b/packages/encrypted-blockstore/src/loader.ts index 7387ecfbc..833039415 100644 --- a/packages/encrypted-blockstore/src/loader.ts +++ b/packages/encrypted-blockstore/src/loader.ts @@ -331,7 +331,7 @@ 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) @@ -339,15 +339,15 @@ export class Loader implements Loadable { 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 diff --git a/packages/encrypted-blockstore/src/transaction.ts b/packages/encrypted-blockstore/src/transaction.ts index 0e272647f..4d412c13a 100644 --- a/packages/encrypted-blockstore/src/transaction.ts +++ b/packages/encrypted-blockstore/src/transaction.ts @@ -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 }