-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
116 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//! Module to bootstrap the p2p node by hooking up all the required services. | ||
use crate::cli::Cli; | ||
|
||
/// Bootstrap the p2p node by hooking up all the required services. | ||
pub(crate) async fn bootstrap(args: Cli) { | ||
todo!() | ||
} |
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,32 @@ | ||
//! Parses command-line arguments for the p2p-client CLI. | ||
use clap::{crate_version, Parser}; | ||
|
||
use crate::constants::{ | ||
DEFAULT_NUM_THREADS, DEFAULT_RPC_HOST, DEFAULT_RPC_PORT, DEFAULT_STACK_SIZE_MB, | ||
}; | ||
|
||
/// CLI arguments for the p2p-client. | ||
#[derive(Debug, Parser)] | ||
#[clap( | ||
name = "strata-bridge", | ||
about = "The bridge node for Strata", | ||
version = crate_version!() | ||
)] | ||
pub(crate) struct Cli { | ||
/// RPC server host for the p2p node. | ||
#[clap(long, help = "RPC server host for the p2p node", default_value_t = DEFAULT_RPC_HOST.to_string())] | ||
pub rpc_host: String, | ||
|
||
/// RPC server port for the p2p node. | ||
#[clap(long, help = "RPC server port for the p2p node", default_value_t = DEFAULT_RPC_PORT)] | ||
pub rpc_port: u32, | ||
|
||
/// The number of tokio threads to use. | ||
#[clap(long, help = "The number of tokio threads to use", default_value_t = DEFAULT_NUM_THREADS)] | ||
pub num_threads: usize, | ||
|
||
/// The stack size per thread (in MB). | ||
#[clap(long, help = "The stack size per thread (in MB)", default_value_t = DEFAULT_STACK_SIZE_MB)] | ||
pub stack_size: usize, | ||
} |
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,13 @@ | ||
//! Constants used throughout the p2p-client. | ||
/// Default RPC host. | ||
pub(crate) const DEFAULT_RPC_HOST: &str = "127.0.0.1"; | ||
|
||
/// Default RPC port. | ||
pub(crate) const DEFAULT_RPC_PORT: u32 = 4780; | ||
|
||
/// Default number of threads. | ||
pub(crate) const DEFAULT_NUM_THREADS: usize = 2; | ||
|
||
/// Default stack size in MB. | ||
pub(crate) const DEFAULT_STACK_SIZE_MB: usize = 512; |
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 |
---|---|---|
@@ -1,3 +1,37 @@ | ||
//! The p2p-client binary main entry point. | ||
#![expect(incomplete_features)] // the generic_const_exprs feature is incomplete | ||
#![feature(generic_const_exprs)] // but necessary for using const generic bounds in p2p crate | ||
|
||
use clap::Parser; | ||
use cli::Cli; | ||
use strata_common::logging::{self, LoggerConfig}; | ||
use tokio::runtime; | ||
use tracing::{info, trace}; | ||
|
||
use crate::bootstrap::bootstrap; | ||
|
||
mod bootstrap; | ||
mod cli; | ||
mod constants; | ||
|
||
/// Main function for the p2p-client binary. | ||
fn main() { | ||
println!("Hello, world!"); | ||
logging::init(LoggerConfig::new("bridge-node".to_string())); | ||
|
||
let cli_args: Cli = Cli::parse(); | ||
|
||
info!("starting node"); | ||
trace!(action = "creating runtime", num_threads = %cli_args.num_threads, stack_size_per_thread_mb = %cli_args.stack_size); | ||
|
||
const NUM_BYTES_PER_MB: usize = 1024 * 1024; | ||
let runtime = runtime::Builder::new_multi_thread() | ||
.worker_threads(cli_args.num_threads) | ||
.thread_stack_size(cli_args.stack_size * NUM_BYTES_PER_MB) | ||
.enable_all() | ||
.build() | ||
.expect("must be able to create runtime"); | ||
|
||
runtime.block_on(async { | ||
bootstrap(cli_args).await; | ||
}); | ||
} |