-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ensure new kv-store is used on the server (#11662)
This PR refactors the last few stores (other than PXE and old merkle trees) to the new async store interface
- Loading branch information
Showing
22 changed files
with
161 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { openTmpStore } from '@aztec/kv-store/lmdb'; | ||
import { openTmpStore } from '@aztec/kv-store/lmdb-v2'; | ||
|
||
import { describeBlobStore } from './blob_store_test_suite.js'; | ||
import { DiskBlobStore } from './disk_blob_store.js'; | ||
|
||
describe('DiskBlobStore', () => { | ||
describeBlobStore(() => new DiskBlobStore(openTmpStore())); | ||
describeBlobStore(async () => new DiskBlobStore(await openTmpStore('test'))); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
import { type AztecKVStore, type AztecMap } from '@aztec/kv-store'; | ||
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store'; | ||
|
||
import { type BlobWithIndex, BlobsWithIndexes } from '../types/index.js'; | ||
import { type BlobStore } from './interface.js'; | ||
|
||
export class DiskBlobStore implements BlobStore { | ||
blobs: AztecMap<string, Buffer>; | ||
blobs: AztecAsyncMap<string, Buffer>; | ||
|
||
constructor(store: AztecKVStore) { | ||
constructor(store: AztecAsyncKVStore) { | ||
this.blobs = store.openMap('blobs'); | ||
} | ||
|
||
public getBlobSidecars(blockId: string, indices?: number[]): Promise<BlobWithIndex[] | undefined> { | ||
const blobBuffer = this.blobs.get(`${blockId}`); | ||
public async getBlobSidecars(blockId: string, indices?: number[]): Promise<BlobWithIndex[] | undefined> { | ||
const blobBuffer = await this.blobs.getAsync(`${blockId}`); | ||
if (!blobBuffer) { | ||
return Promise.resolve(undefined); | ||
return undefined; | ||
} | ||
|
||
const blobsWithIndexes = BlobsWithIndexes.fromBuffer(blobBuffer); | ||
if (indices) { | ||
// If indices are provided, return the blobs at the specified indices | ||
return Promise.resolve(blobsWithIndexes.getBlobsFromIndices(indices)); | ||
return blobsWithIndexes.getBlobsFromIndices(indices); | ||
} | ||
// If no indices are provided, return all blobs | ||
return Promise.resolve(blobsWithIndexes.blobs); | ||
return blobsWithIndexes.blobs; | ||
} | ||
|
||
public async addBlobSidecars(blockId: string, blobSidecars: BlobWithIndex[]): Promise<void> { | ||
await this.blobs.set(blockId, new BlobsWithIndexes(blobSidecars).toBuffer()); | ||
return Promise.resolve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.