Skip to content

Commit

Permalink
Convert blockFilter to use bytes
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Potsides <[email protected]>
  • Loading branch information
jtsmedley and achingbrain authored Jul 26, 2024
1 parent e5fdaf2 commit 55af4eb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/car/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 55af4eb

Please sign in to comment.