From 55af4eb9b4f7b7fb44ffd2295fd6ca11e6339bd1 Mon Sep 17 00:00:00 2001 From: jtsmedley <38006759+jtsmedley@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:14:11 -0500 Subject: [PATCH] Convert blockFilter to use bytes Co-authored-by: Alex Potsides --- packages/car/src/index.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/car/src/index.ts b/packages/car/src/index.ts index cf6c4dcd..23b247be 100644 --- a/packages/car/src/index.ts +++ b/packages/car/src/index.ts @@ -197,14 +197,12 @@ class DefaultCar implements Car { for (const root of roots) { void queue.add(async () => { await this.#walkDag(root, queue, async (cid, bytes) => { - // check if duplicate blocks should be skipped - if (options?.blockFilter != null) { - // skip blocks that have already been written - if (options.blockFilter.has(cid.toString())) { - return - } - options.blockFilter.add(cid.toString()) + // if a filter has been passed, skip blocks that have already been written + if (options?.blockFilter?.has(cid.multihash.bytes) === true) { + return } + + options?.blockFilter?.add(cid.multihash.bytes) await writer.put({ cid, bytes }) }, options) })