Skip to content
Closed
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
14 changes: 11 additions & 3 deletions schema/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export const conditionalOrderGenerator = onchainTable(
chainOwnerIdx: index().on(table.chainId, table.owner),
resolvedOwnerIdx: index().on(table.resolvedOwner),
ownerAddressTypeIdx: index().on(table.ownerAddressType),
checkBlockActiveIdx: index("generator_check_block_active_idx")
.on(table.nextCheckBlock, table.status),
// C1 (OrderDiscoveryPoller) + C5 (CancellationWatcher): per-block SELECT with
// chainId + status + allCandidatesKnown equality filters, ORDER BY lastCheckBlock.
// Covers both handlers — C1 queries allCandidatesKnown=false, C5 queries true.
c1c5PollIdx: index("generator_c1c5_poll_idx")
.on(table.chainId, table.status, table.allCandidatesKnown, table.lastCheckBlock),
})
);

Expand All @@ -111,7 +114,9 @@ export const discreteOrder = onchainTable(
pk: primaryKey({ columns: [table.chainId, table.orderUid] }),
generatorIdx: index("discrete_order_generator_idx")
.on(table.chainId, table.conditionalOrderGeneratorId),
statusIdx: index("discrete_order_status_idx").on(table.status),
// C3 (OrderStatusTracker): per-block SELECT with chainId + status='open', ORDER BY promotedAt.
c3StatusIdx: index("discrete_order_c3_status_idx")
.on(table.chainId, table.status, table.promotedAt),
})
);

Expand All @@ -132,6 +137,9 @@ export const candidateDiscreteOrder = onchainTable(
pk: primaryKey({ columns: [table.chainId, table.orderUid] }),
generatorIdx: index("candidate_discrete_order_generator_idx")
.on(table.chainId, table.conditionalOrderGeneratorId),
// C2 stale sweep: SELECT WHERE chainId + validTo <= timestamp LIMIT 500.
staleIdx: index("candidate_discrete_order_stale_idx")
.on(table.chainId, table.validTo),
})
);

Expand Down
Loading