Fix network diff adjustment prediction algo
This commit is contained in:
5 files changed
+186
-28
No files matched your search
@@ -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 };
|
||||
});
|
||||
|
||||
@@ -166,6 +166,9 @@ export type Snapshot = {
|
||||
cumulative_shares: number;
|
||||
next_block_reward_btc: number;
|
||||
next_difficulty_percent: number;
|
||||
// Observed mean seconds per block so far this epoch, measured between
|
||||
// block timestamps. Absent before the first block of an epoch.
|
||||
epoch_avg_block_seconds?: number;
|
||||
chain: BlockchainInfo | null;
|
||||
network_hashrate_hs: number;
|
||||
recent_blocks?: BlockRecord[];
|
||||
|
||||
Reference in new issue
Block a user