From 3b29c9ff69e1a6195e4d7a770e69245499783ef6 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:27:28 +0200 Subject: [PATCH] Diagnostic data: include SDK version and git hash --- libs/sdk-core/src/breez_services.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index 05d4d5331..2b11cae19 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -185,8 +185,7 @@ impl BreezServices { req: ConnectRequest, event_listener: Box, ) -> BreezServicesResult> { - let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default(); - let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default(); + let (sdk_version, sdk_git_hash) = Self::get_sdk_version(); info!("SDK v{sdk_version} ({sdk_git_hash})"); let start = Instant::now(); let services = BreezServicesBuilder::new(req.config) @@ -199,6 +198,12 @@ impl BreezServices { Ok(services) } + fn get_sdk_version() -> (&'static str, &'static str) { + let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default(); + let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default(); + (sdk_version, sdk_git_hash) + } + /// Internal utility method that starts the BreezServices background tasks for this instance. /// /// It should be called once right after creating [BreezServices], since it is essential for the @@ -2166,6 +2171,8 @@ impl BreezServices { } async fn generate_sdk_diagnostic_data(&self) -> SdkResult { + let (sdk_version, sdk_git_hash) = Self::get_sdk_version(); + let version = format!("SDK v{sdk_version} ({sdk_git_hash})"); let state: String = serde_json::to_string_pretty(&self.persister.get_node_state()?)?; let payments = serde_json::to_string_pretty( &self @@ -2186,6 +2193,7 @@ impl BreezServices { let res = format!( "\ + ***Version***\n{version}\n\n \ ***Node State***\n{state}\n\n \ ***Payments***\n{payments}\n\n \ ***Channels***\n{channels}\n\n \