[modularization] Phase 2: Extract data layer — gitea, weather, bitcoin, loaders (#460)
Some checks failed
Deploy Nexus / deploy (push) Failing after 4s
Staging Smoke Test / smoke-test (push) Failing after 0s

This commit was merged in pull request #460.
This commit is contained in:
2026-03-24 21:28:03 +00:00
parent d201d3e6a9
commit 764b617a2a
11 changed files with 280 additions and 163 deletions

27
modules/data/bitcoin.js Normal file
View File

@@ -0,0 +1,27 @@
// modules/data/bitcoin.js — Blockstream block height polling
// Writes to S: lastKnownBlockHeight, _starPulseIntensity
import { S } from '../state.js';
const BITCOIN_REFRESH_MS = 60 * 1000;
export async function fetchBlockHeight() {
try {
const res = await fetch('https://blockstream.info/api/blocks/tip/height');
if (!res.ok) return null;
const height = parseInt(await res.text(), 10);
if (isNaN(height)) return null;
const isNew = S.lastKnownBlockHeight !== null && height > S.lastKnownBlockHeight;
S.lastKnownBlockHeight = height;
if (isNew) {
S._starPulseIntensity = 1.0;
}
return { height, isNewBlock: isNew };
} catch {
return null;
}
}
export { BITCOIN_REFRESH_MS };