Skip to content

Commit

Permalink
cargroup type
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Jun 5, 2024
1 parent 3eea967 commit c049c93
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/encrypted-blockstore/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function cidListIncludes(list: CarLog, cids: CarGroup) {
}

// this works for car groups because toString looks like bafy,bafy
function uniqueCids(list: CarLog, remove: Set<string> = new Set()): AnyLink[][] {
const byString = new Map<string, AnyLink[]>()
function uniqueCids(list: CarLog, remove: Set<string> = new Set()): CarLog {
const byString = new Map<string, CarGroup>()
for (const cid of list) {
if (remove.has(cid.toString())) continue
byString.set(cid.toString(), cid)
Expand Down Expand Up @@ -64,7 +64,7 @@ export abstract class Loadable {
export class Loader implements Loadable {
name: string
ebOpts: BlockstoreOpts
commitQueue: CommitQueue<AnyLink[]> = new CommitQueue<AnyLink[]>()
commitQueue: CommitQueue<CarGroup> = new CommitQueue<CarGroup>()
isCompacting = false
isWriting = false
remoteMetaStore?: AbstractRemoteMetaStore
Expand Down Expand Up @@ -187,15 +187,15 @@ export class Loader implements Loadable {
t: CarTransaction,
done: TransactionMeta,
opts: CommitOpts = { noLoader: false, compact: false }
): Promise<AnyLink[]> {
): Promise<CarGroup> {
return this.commitQueue.enqueue(() => this._commitInternalFiles(t, done, opts))
}
// can these skip the queue? or have a file queue?
async _commitInternalFiles(
t: CarTransaction,
done: TransactionMeta,
opts: CommitOpts = { noLoader: false, compact: false }
): Promise<AnyLink[]> {
): Promise<CarGroup> {
await this.ready
const { files: roots } = this.makeFileCarHeader(done) as {
files: AnyLink[]
Expand All @@ -214,7 +214,7 @@ export class Loader implements Loadable {
t: CarTransaction,
done: TransactionMeta,
opts: CommitOpts = { noLoader: false, compact: false }
): Promise<AnyLink[]> {
): Promise<CarGroup> {
return this.commitQueue.enqueue(() => this._commitInternal(t, done, opts))
}

Expand Down Expand Up @@ -242,7 +242,7 @@ export class Loader implements Loadable {
t: CarTransaction,
done: TransactionMeta,
opts: CommitOpts = { noLoader: false, compact: false }
): Promise<AnyLink[]> {
): Promise<CarGroup> {
await this.ready
const fp = this.makeCarHeader(done, this.carLog, !!opts.compact) as CarHeader
let roots: AnyLink[] = await this.prepareRoots(fp, t)
Expand Down

0 comments on commit c049c93

Please sign in to comment.