feat: add logical game clock

This commit is contained in:
2026-08-04 02:51:27 +00:00
parent 87965a39d6
commit a26031dc3f
51 changed files with 1605 additions and 398 deletions
@@ -47,15 +47,18 @@ const syncAuctionTimers = async (
): Promise<number> => {
const auctions = await db.auction.findMany({
where: { status: 'OPEN' },
select: { id: true, closeAt: true },
select: { id: true, closeAt: true, closeTick: true },
});
if (auctions.length > 0) {
await redis.zAdd(
`sammo:${profileName}:auction:timer`,
auctions.map((auction) => ({
score: auction.closeAt.getTime(),
value: String(auction.id),
}))
auctions.map((auction) => {
const score = auction.closeTick == null ? auction.closeAt.getTime() : Number(auction.closeTick);
if (!Number.isSafeInteger(score)) {
throw new Error(`Auction ${auction.id} has an unsafe logical deadline: ${auction.closeTick}`);
}
return { score, value: String(auction.id) };
})
);
}
return auctions.length;