Fix network diff adjustment prediction algo

This commit is contained in:
satoshi committed 2026-09-02 06:44:07 +03:00
1 parent 89e9b32efd
commit 3df739e5b3
5 files changed
+186 -28

No files matched your search

+6 -2
View File
@@ -36,12 +36,16 @@
});
// Blocks remaining + ETA until the retarget. The predicted adjustment
// percent comes from the backend (computed from the epoch start time).
// percent comes from the backend (measured between block timestamps
// from the epoch's first block), as does the epoch's observed mean
// block time — projecting the ETA at the pace the network is actually
// keeping rather than a flat 600s, which is what mempool.space shows.
const retarget = $derived.by(() => {
if (!height) return { remaining: 2016, eta: "", progress: 0 };
const inEpoch = height % 2016;
const remaining = 2016 - inEpoch;
const etaSec = remaining * 600;
const avgBlockSec = data.epoch_avg_block_seconds || 600;
const etaSec = remaining * avgBlockSec;
const progress = (inEpoch / 2016) * 100;
return { remaining, eta: formatDuration(etaSec), progress };
});