-
Notifications
You must be signed in to change notification settings - Fork 38
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
9 changed files
with
109 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,2 @@ | ||
# keep the `pkg` directory (rust_embed macro fails without it), but don't track the contents | ||
* |
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,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>celestia-node-rs</title> | ||
<script type="module" src="/js/run_node.js"></script> | ||
</head> | ||
<body> | ||
<h1>Celestia Node</h1> | ||
<h2>Network</h2> | ||
<select id="network_id"> | ||
<option value="0">Arabica</option> | ||
<option value="1">Mocha</option> | ||
<option value="2">Private</option> | ||
</select> | ||
<h2>Bootnodes</h2> | ||
<textarea id="bootnodes" cols=80 rows=10> | ||
</textarea> | ||
<h2>Genesis Hash</h2> | ||
<input type="text" id="genesis" size=80 /> | ||
|
||
<button id="start">Start!</button> | ||
|
||
<h3>Status</h3> | ||
<h4>PeerId</h4><div id="peer_id"></div> | ||
<h4>Syncer</h4><div id="syncer"></div> | ||
<h4>Peers</h4><div id="peers"></div> | ||
</body> | ||
</html> |
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 @@ | ||
Error.stackTraceLimit = 99; | ||
|
||
import init, { setup, Network, WasmNode, WasmNodeConfig, canonical_network_bootnodes, network_genesis } from "/wasm/wasm_node.js"; | ||
|
||
// initialize wasm | ||
await init(); | ||
// setup logging and console panic hook | ||
await setup(); | ||
|
||
const response = await fetch('/cfg.json'); | ||
const json = await response.json(); | ||
|
||
console.log("Received config:", json); | ||
|
||
const network = json.network; | ||
let bootnodes = json.bootnodes | ||
if (bootnodes.length === 0) { | ||
bootnodes = canonical_network_bootnodes(network); | ||
} | ||
const genesis = network_genesis(network); | ||
|
||
document.getElementById("network_id").value = network; | ||
document.getElementById("genesis").value = genesis; | ||
document.getElementById("bootnodes").value = bootnodes.join("\n"); | ||
|
||
document.getElementById("start").addEventListener("click", async function(ev) { | ||
document.getElementById("start").setAttribute("disabled", "disabled"); | ||
|
||
const network = Number(document.getElementById("network_id").value); | ||
const genesis = document.getElementById("genesis").value; | ||
const bootnodes = document.getElementById("bootnodes").value.split("\n"); | ||
|
||
console.log("starting with:", network, bootnodes, genesis); | ||
|
||
const config = new WasmNodeConfig(network, genesis, bootnodes); | ||
window.node = await new WasmNode(config); | ||
|
||
setInterval(async function() { | ||
document.getElementById("peer_id").innerText = JSON.stringify(await window.node.local_peer_id()); | ||
document.getElementById("syncer").innerText = JSON.stringify(await window.node.syncer_info()); | ||
document.getElementById("peers").innerText = JSON.stringify(await window.node.connected_peers()); | ||
}, 1000); | ||
|
||
}, false); |
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
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