Files
p2p/client-gui/src/main.rs
Tiago Batista Cardoso 10b77f8635 tidy
2026-01-25 03:25:54 +01:00

43 lines
1.4 KiB
Rust

use crate::gui_app::P2PClientApp;
use client_network::{NetworkCommand, NetworkEvent, P2PSharedData, start_p2p_executor};
mod gui_app;
#[tokio::main]
async fn main() -> eframe::Result<()> {
// 1. Setup Channels
let (network_cmd_tx, network_cmd_rx) = crossbeam_channel::unbounded::<NetworkCommand>();
let (network_event_tx, network_event_rx) = crossbeam_channel::unbounded::<NetworkEvent>();
// 2. Start the P2P Network Executor in a separate Tokio task
// The executor runs in the background of our main async runtime.
let shared_data: Option<P2PSharedData> = None;
let _network_handle = start_p2p_executor(network_cmd_rx, network_event_tx, shared_data);
// 3. Configure and Run the Eframe/Egui GUI
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([700.0, 500.0])
.with_min_inner_size([700.0, 500.0])
.with_resizable(false)
.with_icon(
eframe::icon_data::from_png_bytes(include_bytes!("../assets/icon.png"))
.expect("Failed to load icon"),
),
..Default::default()
};
eframe::run_native(
"p2p-merkle client",
options,
Box::new(|_| {
let app = P2PClientApp::new(network_cmd_tx, network_event_rx);
Ok(Box::new(app))
}),
)
// Starts the protocol
}