Skip to content

Commit

Permalink
Added basic blessed-contrib display
Browse files Browse the repository at this point in the history
  • Loading branch information
sfaber34 committed Apr 28, 2024
1 parent ee5d5eb commit 4f2e2fe
Showing 1 changed file with 50 additions and 22 deletions.
72 changes: 50 additions & 22 deletions packages/nextjs/public/bgnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ args.forEach((val, index) => {
}
});

function startChain(jwtDir) {
function startChain(executionClient, consensusClient, jwtDir) {
// Create a screen object
const screen = blessed.screen();

console.log(executionClient);

// Create two log boxes
const executionLog = contrib.log({
fg: "green",
Expand All @@ -82,19 +84,34 @@ function startChain(jwtDir) {
screen.append(consensusLog);
screen.render();

// Start geth as a child process
const execution = spawn("geth", [
"--mainnet",
"--http",
"--http.api",
"eth,net,engine,admin",
"--http.addr",
"0.0.0.0",
"--syncmode",
"full",
"--authrpc.jwtsecret",
`${jwtDir}/jwt.hex`,
]);
let execution;
if (executionClient === "geth") {
execution = spawn("geth", [
"--mainnet",
"--http",
"--http.api",
"eth,net,engine,admin",
"--http.addr",
"0.0.0.0",
"--syncmode",
"full",
"--authrpc.jwtsecret",
`${jwtDir}/jwt.hex`,
]);
} else if (executionClient === "reth") {
execution = spawn("geth", [
"--mainnet",
"--http",
"--http.api",
"eth,net,engine,admin",
"--http.addr",
"0.0.0.0",
"--syncmode",
"full",
"--authrpc.jwtsecret",
`${jwtDir}/jwt.hex`,
]);
}

execution.stdout.on("data", data => {
executionLog.log(data.toString());
Expand All @@ -106,13 +123,24 @@ function startChain(jwtDir) {

const prysmDir = path.join(os.homedir(), "bgnode", "prysm");

const consensus = spawn(`${prysmDir}/prysm.sh`, [
"beacon-chain",
"--execution-endpoint=http://localhost:8551",
"--mainnet",
"--jwt-secret",
`${jwtDir}/jwt.hex`,
]);
let consensus;
if (consensusClient === "prysm") {
consensus = spawn(`${prysmDir}/prysm.sh`, [
"beacon-chain",
"--execution-endpoint=http://localhost:8551",
"--mainnet",
"--jwt-secret",
`${jwtDir}/jwt.hex`,
]);
} else if (consensusClient === "lighthouse") {
consensus = spawn(`${prysmDir}/prysm.sh`, [
"beacon-chain",
"--execution-endpoint=http://localhost:8551",
"--mainnet",
"--jwt-secret",
`${jwtDir}/jwt.hex`,
]);
}

consensus.stdout.on("data", data => {
consensusLog.log(data.toString());
Expand Down Expand Up @@ -303,4 +331,4 @@ if (["darwin", "linux"].includes(os.platform())) {
}
}

startChain(jwtDir);
startChain(executionClient, consensusClient, jwtDir);

0 comments on commit 4f2e2fe

Please sign in to comment.