UNPKG

@atproto/repo

Version:

atproto repo and MST implementation

29 lines 912 B
import { ReadableBlockstore } from './readable-blockstore.js'; export class SyncStorage extends ReadableBlockstore { constructor(staged, saved) { super(); this.staged = staged; this.saved = saved; } async getBytes(cid) { const got = await this.staged.getBytes(cid); if (got) return got; return this.saved.getBytes(cid); } async getBlocks(cids) { const fromStaged = await this.staged.getBlocks(cids); const fromSaved = await this.saved.getBlocks(fromStaged.missing); const blocks = fromStaged.blocks; blocks.addMap(fromSaved.blocks); return { blocks, missing: fromSaved.missing, }; } async has(cid) { return (await this.staged.has(cid)) || (await this.saved.has(cid)); } } export default SyncStorage; //# sourceMappingURL=sync-storage.js.map