0.7.22
This commit is contained in:
1494
kb_app/src/demo_pipeline.rs
Normal file
1494
kb_app/src/demo_pipeline.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod demo_http;
|
||||
mod demo_pipeline;
|
||||
mod demo_ws;
|
||||
mod demo_ws_manager;
|
||||
mod splash;
|
||||
@@ -36,16 +37,18 @@ impl KbWsRuntimeState {
|
||||
/// Shared application state stored inside Tauri.
|
||||
struct KbAppState {
|
||||
config: kb_lib::KbConfig,
|
||||
database: std::sync::Arc<kb_lib::KbDatabase>,
|
||||
ws_runtime: tokio::sync::Mutex<KbWsRuntimeState>,
|
||||
demo_ws_runtime: std::sync::Arc<tokio::sync::Mutex<crate::demo_ws::KbDemoWsRuntimeState>>,
|
||||
demo_ws_manager_runtime: std::sync::Arc<tokio::sync::Mutex<crate::demo_ws_manager::KbDemoWsManagerRuntimeState>>,
|
||||
demo_ws_manager_runtime:
|
||||
std::sync::Arc<tokio::sync::Mutex<crate::demo_ws_manager::KbDemoWsManagerRuntimeState>>,
|
||||
ws_manager: std::sync::Arc<kb_lib::WsManager>,
|
||||
http_pool: kb_lib::HttpEndpointPool,
|
||||
}
|
||||
|
||||
/// Runs the desktop application.
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
pub async fn run() -> Result<(), kb_lib::KbError> {
|
||||
let config_path = kb_lib::KbConfig::default_path();
|
||||
let config_result = kb_lib::KbConfig::load_from_path(&config_path);
|
||||
let config = match config_result {
|
||||
@@ -56,20 +59,20 @@ pub fn run() {
|
||||
config_path.display(),
|
||||
error
|
||||
);
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
let prepare_result = config.prepare_filesystem();
|
||||
if let Err(error) = prepare_result {
|
||||
eprintln!("kb_app filesystem preparation error: {error}");
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
let tracing_guard_result = kb_lib::init_tracing(&config.logging);
|
||||
let _tracing_guard = match tracing_guard_result {
|
||||
Ok(guard) => guard,
|
||||
Err(error) => {
|
||||
eprintln!("kb_app tracing initialization error: {error}");
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
tracing::info!(
|
||||
@@ -77,6 +80,11 @@ pub fn run() {
|
||||
environment = %config.app.environment,
|
||||
"starting desktop application"
|
||||
);
|
||||
let database_result = kb_lib::KbDatabase::connect_and_initialize(&config.database).await;
|
||||
let database = match database_result {
|
||||
Ok(database) => database,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let http_pool_result = kb_lib::HttpEndpointPool::from_config(&config);
|
||||
let http_pool = match http_pool_result {
|
||||
Ok(http_pool) => http_pool,
|
||||
@@ -95,6 +103,7 @@ pub fn run() {
|
||||
};
|
||||
let app_state = KbAppState {
|
||||
config: config.clone(),
|
||||
database: std::sync::Arc::new(database),
|
||||
ws_runtime: tokio::sync::Mutex::new(KbWsRuntimeState::new()),
|
||||
demo_ws_runtime: std::sync::Arc::new(tokio::sync::Mutex::new(
|
||||
crate::demo_ws::KbDemoWsRuntimeState::new(),
|
||||
@@ -128,6 +137,11 @@ pub fn run() {
|
||||
crate::demo_ws_manager::demo_ws_manager_stop_all,
|
||||
crate::demo_ws_manager::demo_ws_manager_start_role,
|
||||
crate::demo_ws_manager::demo_ws_manager_stop_role,
|
||||
crate::demo_pipeline::open_demo_pipeline_window,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_signature,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_token_mint,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_pair_id,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_pool_address,
|
||||
]);
|
||||
tauri_builder = tauri_builder.plugin(tracing_builder.build::<tauri::Wry>());
|
||||
tauri_builder = tauri_builder.setup(|app| {
|
||||
@@ -202,7 +216,11 @@ pub fn run() {
|
||||
let run_result = tauri_builder.run(tauri::generate_context!());
|
||||
if let Err(error) = run_result {
|
||||
tracing::error!("error while running tauri application: {error:?}");
|
||||
return Err(kb_lib::KbError::InvalidState(format!(
|
||||
"error while running tauri application: {error:?}"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_splash_order(
|
||||
|
||||
@@ -14,9 +14,7 @@ use fs2::FileExt;
|
||||
|
||||
/// Entrypoint of the kb app binary.
|
||||
#[tokio::main]
|
||||
async
|
||||
fn main() -> std::process::ExitCode
|
||||
{
|
||||
async fn main() -> std::process::ExitCode {
|
||||
let mut lock_path = std::env::temp_dir();
|
||||
lock_path.push("com_khadhroony_solana_rust.lock");
|
||||
let lock_file = match std::fs::File::create(lock_path) {
|
||||
@@ -24,7 +22,7 @@ fn main() -> std::process::ExitCode
|
||||
Err(_err) => {
|
||||
eprintln!("Cannot create lock!");
|
||||
std::process::exit(1);
|
||||
},
|
||||
}
|
||||
};
|
||||
// trying to aquire an exclusive lock
|
||||
if lock_file.try_lock_exclusive().is_err() {
|
||||
@@ -34,13 +32,17 @@ fn main() -> std::process::ExitCode
|
||||
if rustls::crypto::CryptoProvider::get_default().is_none() {
|
||||
let provider_result = rustls::crypto::aws_lc_rs::default_provider().install_default();
|
||||
match provider_result {
|
||||
Ok(()) => {},
|
||||
Ok(()) => {}
|
||||
Err(error) => {
|
||||
eprintln!("kb_app rustls provider init error: {:?}", error);
|
||||
return std::process::ExitCode::FAILURE;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
kb_app_lib::run();
|
||||
}
|
||||
let run_result = kb_app_lib::run().await;
|
||||
if let Err(error) = run_result {
|
||||
eprintln!("application error: {}", error);
|
||||
std::process::exit(1);
|
||||
}
|
||||
std::process::ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user