Catalog: 20s cache so ladder pages stop waiting on five live quotes
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -88,6 +88,7 @@ async function uplineSlides(email, depth = 3) {
|
||||
// positions 2 and 3 become theirs at 2 and 5 qualifying buyers (the same
|
||||
// thresholds that open payout levels 2 and 3). Until then, or while an unlocked
|
||||
// slot is empty, the slot shows an upline's banner, then a house ad.
|
||||
const catalogCache = { at: 0, products: null };
|
||||
const wallUnlockedFor = bc => (bc >= 5 ? 3 : bc >= 2 ? 2 : 1);
|
||||
// every on-chain member id this session controls: the main wallet plus linked
|
||||
// positions (Qualified Start). Credits pool across them on the dashboard.
|
||||
@@ -545,7 +546,13 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { url: 'https://www.moonpay.com/buy/pol', signed: false, pol });
|
||||
}
|
||||
if (p === '/api/catalog' && req.method === 'GET') {
|
||||
return json(res, 200, { products: await chain.catalog() });
|
||||
// five live quotes per call: serve a 20-second cache so pages that load the
|
||||
// ladder (join, home, buy) are not waiting on the RPC every time
|
||||
if (!catalogCache.at || Date.now() - catalogCache.at > 20000) {
|
||||
try { catalogCache.products = await chain.catalog(); catalogCache.at = Date.now(); }
|
||||
catch (e) { if (!catalogCache.products) throw e; }
|
||||
}
|
||||
return json(res, 200, { products: catalogCache.products });
|
||||
}
|
||||
if (p === '/api/feed' && req.method === 'GET') {
|
||||
return json(res, 200, { events: await attachNames(chain.recentEvents(Number(u.searchParams.get('n')) || 100)) });
|
||||
|
||||
Reference in New Issue
Block a user