Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/core/src/cache/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ afterEach(async () => {
});

describe("BitcoinmintsDB schema", () => {
it("opens at version 1 with all 6 tables present", async () => {
it("opens at version 2 with all 6 tables present", async () => {
const db = new BitcoinmintsDB(freshName());
toDispose.push(db);
await db.open();

expect(db.verno).toBe(1);
// v2 adds the [kind+createdAt] compound index to announcements (used by
// restoreWatermarks for bounded .last() lookups per kind).
expect(db.verno).toBe(2);
const names = db.tables.map((t) => t.name).sort();
expect(names).toEqual(
["announcements", "mintAggregate", "mintInfo", "profiles", "relayLists", "reviews"].sort(),
Expand Down Expand Up @@ -60,8 +62,14 @@ describe("BitcoinmintsDB schema", () => {
.schema.indexes.map((ix) => ix.name)
.sort();

// announcements secondary indexes: eventId, kind, d, createdAt
expect(indexNames("announcements")).toEqual(["createdAt", "d", "eventId", "kind"]);
// announcements secondary indexes: eventId, kind, d, createdAt + compound [kind+createdAt]
expect(indexNames("announcements")).toEqual([
"[kind+createdAt]",
"createdAt",
"d",
"eventId",
"kind",
]);
// reviews secondary indexes: eventId, d, createdAt, k
expect(indexNames("reviews")).toEqual(["createdAt", "d", "eventId", "k"]);
// mintInfo secondary: fetchedAt, ok
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/cache/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,14 @@ export class BitcoinmintsDB extends Dexie {
mintInfo: "d, fetchedAt, ok",
mintAggregate: "d, bayesianRank, updatedAt",
});
// v2: add compound `[kind+createdAt]` index on announcements so the
// scheduler's restoreWatermarks() can do a bounded `.last()` lookup
// per kind instead of materializing the entire table via .sortBy().
// Dexie auto-migrates additive index changes; existing rows get re-
// indexed on first open. fake-indexeddb supports compound indexes
// (verified in scheduler.restoreWatermarks watermark-restore tests).
this.version(2).stores({
announcements: "[pubkey+kind+d], eventId, kind, d, createdAt, [kind+createdAt]",
});
}
}
10 changes: 10 additions & 0 deletions packages/core/src/cashu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {
createMintInfoFetcher,
type FetchMintInfoOptions,
fetchMintInfo,
type MintInfoFetcher,
type MintInfoFetcherOptions,
type MintInfoResult,
type MintInfoV1,
} from "./info";
export { type LayerBResult, verifySignerBinding } from "./layerB";
Loading
Loading