aboutsummaryrefslogtreecommitdiff
path: root/challenge.html
diff options
context:
space:
mode:
Diffstat (limited to 'challenge.html')
-rw-r--r--challenge.html29
1 files changed, 2 insertions, 27 deletions
diff --git a/challenge.html b/challenge.html
index 73f25a3..fef46a8 100644
--- a/challenge.html
+++ b/challenge.html
@@ -44,7 +44,7 @@
*/
</script>
</head>
-<body>
+<body data-identifier="{{ .Identifier }}" data-difficulty="{{ .Global.NeedBits }}">
<main>
<header>
<h1>Proof-of-work challenge</h1>
@@ -84,32 +84,7 @@
</section>
</main>
- <script>
- document.addEventListener("DOMContentLoaded", async function() {
- let challenge_b64 = "{{ .Identifier }}";
- let difficulty = {{ .Global.NeedBits }};
- let form = document.querySelector("form");
- let field = form.querySelector("input[name='powxy']");
- let status_el = document.getElementById("solver_status");
-
- let identifier_bytes = Uint8Array.from(
- atob(challenge_b64),
- ch => ch.charCodeAt(0)
- );
-
- status_el.textContent = "Starting WebAssembly solver as a worker...";
-
- let worker = new Worker("/.powxy/static/solver.js");
-
- worker.onmessage = function(e) {
- let { nonce, nonce_bytes } = e.data;
- let nonce_str = String.fromCharCode(...nonce_bytes);
- field.value = btoa(nonce_str);
- status_el.textContent = "Challenge solved automatically in " + nonce + " iterations";
- };
-
- worker.postMessage({ identifier_bytes, difficulty });
- });
+ <script src="/.powxy/static/main.js">
</script>
</body>
</html>