-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script> | ||
const HEIGHT_2_5 = 839444; | ||
async function main() { | ||
const current = await (await fetch("https://api.blockcypher.com/v1/btc/main")).json(); | ||
const current_height = current.height; | ||
const current_date = new Date(current.time); | ||
|
||
if (current_height >= HEIGHT_2_5) { | ||
document.getElementById("main").innerHTML = `Stacks 2.5 epoch height reached!`; | ||
} else { | ||
let approximation_height = current_height - (HEIGHT_2_5 - current_height); | ||
const prior = await (await fetch(`https://api.blockcypher.com/v1/btc/main/blocks/${approximation_height}?txstart=1&limit=1`)).json(); | ||
const prior_date = new Date(prior.time); | ||
|
||
let second_approximation_height = current_height - 4 * (HEIGHT_2_5 - current_height); | ||
const second_prior = await (await fetch(`https://api.blockcypher.com/v1/btc/main/blocks/${second_approximation_height}?txstart=1&limit=1`)).json(); | ||
const second_prior_date = new Date(second_prior.time); | ||
|
||
const seconds_delta = current_date - prior_date; | ||
const second_seconds_delta = (current_date - second_prior_date)/4; | ||
const expected_seconds_delta = (seconds_delta + second_seconds_delta) / 2; | ||
|
||
const expected_date = new Date(current_date.getTime() + expected_seconds_delta); | ||
|
||
document.getElementById("block_target").innerHTML = `<b>${HEIGHT_2_5}</b>`; | ||
document.getElementById("current_block").innerHTML = `<b>${current_height}</b>`; | ||
document.getElementById("expected_date").innerHTML = `<b>${expected_date}</b>`; | ||
document.getElementById("blocks_to_go").innerHTML = `<b>${HEIGHT_2_5 - current_height}</b>`; | ||
document.getElementById("used_block").innerHTML = `<b>${approximation_height}</b>`; | ||
document.getElementById("used_block_time").innerHTML = `<b>${prior_date}</b>`; | ||
document.getElementById("time_ago").innerHTML = `<b>${Math.floor(seconds_delta / 3600.0 / 10)/ 100.0}</b>`; | ||
} | ||
} | ||
main(); | ||
</script> | ||
<h1>Wen 2.5 activate?</h1> | ||
<div id="main"> | ||
<p>Current block is <span id="current_block"></span>.</p> | ||
<p>A first-order estimation of 2.5 epoch start is: <span id="expected_date"></span>.</p> | ||
<p></p> | ||
<p>Stacks 2.5 epoch start (bitcoin block <span id="block_target"></span>) is <span id="blocks_to_go"></span> blocks away.</p> | ||
<p></p> | ||
<p>That many blocks ago was height = <span id="used_block"></span> which occured at <span id="used_block_time"></span>, <span id="time_ago"></span> hours ago.</p> | ||
</div> |